sync

fun sync(context: Context, callback: SyncCallback? = null)

Checks with live updates to see if any new builds are available. If they are, attempt to download, unzip, and update the saved data to reference the latest build.

Example usage (kotlin):

LiveUpdateManager.sync(context)

// Sync with a callback
LiveUpdateManager.sync(context, callback = object : SyncCallback {
override fun onAppComplete(syncResult: SyncResult) {
Log.d("LiveUpdate","CALLBACK: Sync success for app ${syncResult.liveUpdate.appId}!")
}

override fun onAppComplete(failResult: FailResult) {
Log.e("LiveUpdate","CALLBACK: Sync failed at step ${failResult.failStep.name} for app ${failResult.liveUpdate.appId}!")
}

override fun onSyncComplete() {
Log.d("LiveUpdate","CALLBACK: Sync finished!")
}
})

Example usage (Java):

Long lastSync = LiveUpdateManager.getLastSync(context);

// Sync with a callback
LiveUpdateManager.sync(this, new SyncCallback() {
@Override
public void onAppComplete(@NonNull SyncResult syncResult) {
Log.d("LiveUpdate","CALLBACK: Sync success for app " + syncResult.getLiveUpdate().getAppId());
}

@Override
public void onAppComplete(@NonNull FailResult failResult) {
Log.d("LiveUpdate","CALLBACK: Sync failed at step " + failResult.getFailStep().name() + " for app " + failResult.getLiveUpdate().getAppId());
}

@Override
public void onSyncComplete() {
Log.d("LiveUpdate","CALLBACK: Sync finished!");
}
});

Parameters

context

an Android Context used during the app update operation

callback

a SyncCallback to notify on each app sync complete and when sync is complete


fun sync(context: Context, appId: String, callback: SyncCallback? = null)

Checks a single app with live updates to see if any new builds are available. If they are, attempt to download, unzip, and update the saved data to reference the latest build.

Example usage (kotlin):

LiveUpdateManager.sync(context, "appId")

// Sync with a callback
LiveUpdateManager.sync(context, "appId", callback = object : SyncCallback {
override fun onAppComplete(syncResult: SyncResult) {
Log.d("LiveUpdate","CALLBACK: Sync success for app ${syncResult.liveUpdate.appId}!")
}

override fun onAppComplete(failResult: FailResult) {
Log.e("LiveUpdate","CALLBACK: Sync failed at step ${failResult.failStep.name} for app ${failResult.liveUpdate.appId}!")
}

override fun onSyncComplete() {
Log.d("LiveUpdate","CALLBACK: Sync finished!")
}
})

Example usage (Java):

Long lastSync = LiveUpdateManager.getLastSync(context, "appId");

// Sync with a callback
LiveUpdateManager.sync(this, "appId", new SyncCallback() {
@Override
public void onAppComplete(@NonNull SyncResult syncResult) {
Log.d("LiveUpdate","CALLBACK: Sync success for app " + syncResult.getLiveUpdate().getAppId());
}

@Override
public void onAppComplete(@NonNull FailResult failResult) {
Log.d("LiveUpdate","CALLBACK: Sync failed at step " + failResult.getFailStep().name() + " for app " + failResult.getLiveUpdate().getAppId());
}

@Override
public void onSyncComplete() {
Log.d("LiveUpdate","CALLBACK: Sync finished!");
}
});

Parameters

context

an Android Context used during the app update operation

appId

a registered appId to sync

callback

a SyncCallback to notify on each app sync complete and when sync is complete


fun sync(context: Context, appIds: Array<String> = arrayOf(), async: Boolean = true, callback: SyncCallback? = null)

Checks all apps or a provided set of apps with live updates to see if any new builds are available. If they are, attempt to download, unzip, and update the saved data to reference the latest build.

Example usage (kotlin):

LiveUpdateManager.sync(context, arrayOf("appId1", "appId2"))

// Sync with a callback
LiveUpdateManager.sync(context, arrayOf("appId1", "appId2"), async = false, callback = object : SyncCallback {
override fun onAppComplete(syncResult: SyncResult) {
Log.d("LiveUpdate","CALLBACK: Sync success for app ${syncResult.liveUpdate.appId}!")
}

override fun onAppComplete(failResult: FailResult) {
Log.e("LiveUpdate","CALLBACK: Sync failed at step ${failResult.failStep.name} for app ${failResult.liveUpdate.appId}!")
}

override fun onSyncComplete() {
Log.d("LiveUpdate","CALLBACK: Sync finished!")
}
})

Example usage (Java):

Long lastSync = LiveUpdateManager.getLastSync(context, new String[] {"appId1", "appId2"});

// Sync with a callback
LiveUpdateManager.sync(this, new String[] {"appId1", "appId2"}, false, new SyncCallback() {
@Override
public void onAppComplete(@NonNull SyncResult syncResult) {
Log.d("LiveUpdate","CALLBACK: Sync success for app " + syncResult.getLiveUpdate().getAppId());
}

@Override
public void onAppComplete(@NonNull FailResult failResult) {
Log.d("LiveUpdate","CALLBACK: Sync failed at step " + failResult.getFailStep().name() + " for app " + failResult.getLiveUpdate().getAppId());
}

@Override
public void onSyncComplete() {
Log.d("LiveUpdate","CALLBACK: Sync finished!");
}
});

Parameters

context

an Android Context used during the app update operation

appIds

an array of registered appId's to sync, default of empty array will sync all apps

async

whether to run updates in parallel or not (true by default)

callback

a SyncCallback to notify on each app sync complete and when sync is complete