Skip to main content

Syncing a Portal with Live Updates

The sync operation checks Appflow for a new version of a web app used in a Portal. If an update is available, the files are downloaded and the Portal is updated to use those new files the next time it loads. The Live Updates SDK will perform a sync when the Live Update Config is added to a Portal by default. This is typically done when an app is initially launched, and requires a full restart of an app to trigger subsequent syncs. We recommend performing a sync in other situations to provide more chances for Portals to update.

Triggering a Sync#

A sync can be triggered by calling the sync function in the Live Update Manager.

// Sync all appsLiveUpdateManager.sync()
// Sync a specific appLiveUpdateManager.sync(appId: "appId")
// Sync all apps not in parallel and with a callbackprivate class MyLiveUpdateCallbacks: ISyncCallback {    func onAppComplete(_ liveUpdate: LiveUpdate) { print("Single Sync completed!") }    func onSyncComplete() { print("Sync completed!") }}
LiveUpdateManager.sync(isParallel = false, callbacks = MyLiveUpdateCallbacks())

When to Sync#

Deciding when to sync is at your discretion.


Depending on the size of your web app assets, a sync operation could be expensive. Keep in mind that mobile users may be on a cellular network data connection or may be opening the app from a mininized or background state to use it.

The following example performs a sync when an app resumes as long as six hours has elapsed since the previous sync. This ensures a check is performed every time a user opens the app whether it is opened for the first time or opened from a minimized state.

// Placed in an iOS View Controlleroverride fun viewDidLoad() {  // If it has been more than 6 hours since last update check, sync now.  let lastUpdateTime = LiveUpdateManager.getLastSync(this)  let sixHoursAgo = .hour, value: -6, to: Date())
  if(lastUpdateTime < sixHoursAgo) {    LiveUpdateManager.sync(this)  }