Skip to content

Syncing updates

sync() runs the whole cycle: check for an update, download it, install it, and report status. The wrapper calls it for you on the schedule set by checkFrequency; call it yourself for manual control:

export default CodePush({ checkFrequency: CodePush.CheckFrequency.MANUAL })(App);
CodePush.sync(
{ installMode: CodePush.InstallMode.ON_NEXT_RESTART },
(status) => console.log("sync status", status),
({ receivedBytes, totalBytes }) => console.log(receivedBytes / totalBytes)
);

The signature is sync(options?, syncStatusChangedCallback?, downloadProgressCallback?, handleBinaryVersionMismatchCallback?) and it resolves to a SyncStatus. Options are the same as the wrapper’s, minus checkFrequency. A second sync() while one is running resolves to SyncStatus.SYNC_IN_PROGRESS without starting anything.

  • IMMEDIATE: restart the app now and run the update. Default for mandatory updates.
  • ON_NEXT_RESTART: run it the next time the app starts. Default for optional updates.
  • ON_NEXT_RESUME: run it when the app comes back from the background.
  • ON_NEXT_SUSPEND: install while the app is in the background, after minimumBackgroundDuration seconds.

After an update runs, the SDK confirms it with the server. A crash before confirmation rolls the device back to the previous bundle and reports a failed deployment, which shows up in aether deployment history as described in the update lifecycle. When you drive updates manually with the lower-level API instead of sync(), call notifyAppReady() yourself; sync() does it for you.