Sync and Install Modes

Check, download, and schedule updates with the high-level sync helper.

Edit
import { InstallMode, SyncStatus, sync } from '@nitropush/react-native';
 
async function checkForUpdates() {
  await sync(
    client,
    {
      installMode: InstallMode.ON_NEXT_RESUME,
      mandatoryInstallMode: InstallMode.IMMEDIATE,
      minimumBackgroundDuration: 60,
    },
    (status, error) => {
      console.log(SyncStatus[status], error);
    },
    ({ receivedBytes, totalBytes }) => {
      console.log(`${receivedBytes}/${totalBytes}`);
    },
  );
}

Install modes

ModeActivation
IMMEDIATERestart after installation
ON_NEXT_RESTARTNext cold launch
ON_NEXT_RESUMENext eligible foreground transition
ON_NEXT_SUSPENDWhen the app backgrounds, ready for the following resume

sync() coalesces concurrent calls for the same client and reports every check, download, install, and error transition through the status callback.

On this page