Skip to content

Commit

Permalink
feat: support live updates 0.5.0 and will use portal web app director…
Browse files Browse the repository at this point in the history
…y as a source for differential updates (#62)
  • Loading branch information
carlpoole authored Feb 5, 2024
1 parent 8a7c1a8 commit 0c4886d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion IonicPortals/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies {
implementation(kotlin("reflect"))

api("com.capacitorjs:core:[5.5.0,5.6.0)")
compileOnly("io.ionic:liveupdates:0.4.1")
compileOnly("io.ionic:liveupdates:0.5.0")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
implementation("androidx.core:core-ktx:1.10.0")
Expand Down
12 changes: 12 additions & 0 deletions IonicPortals/src/main/kotlin/io/ionic/portals/Portal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ class Portal(val name: String) {
* A LiveUpdate config, if live updates is being used.
*/
var liveUpdateConfig: LiveUpdate? = null
set(value) {
field = value
if (value != null) {
if(value.assetPath == null) {
value.assetPath = this.startDir
}
}
}

/**
* Whether to run a live update sync when the portal is added to the manager.
Expand Down Expand Up @@ -534,6 +542,10 @@ class PortalBuilder(val name: String) {
@JvmOverloads
fun setLiveUpdateConfig(context: Context, liveUpdateConfig: LiveUpdate, updateOnAppLoad: Boolean = true): PortalBuilder {
this.liveUpdateConfig = liveUpdateConfig
if(liveUpdateConfig.assetPath == null) {
liveUpdateConfig.assetPath = this._startDir ?: this.name
}

LiveUpdateManager.initialize(context)
LiveUpdateManager.cleanVersions(context, liveUpdateConfig.appId)
LiveUpdateManager.addLiveUpdateInstance(context, liveUpdateConfig)
Expand Down

0 comments on commit 0c4886d

Please sign in to comment.