After a new version of the
bundle.js file of your Mobile Development Kit app is uploaded and deployed to Mobile Services, it is ready to be downloaded to the Mobile Development Kit Client installed on the user's device.
App Update Process¶
In the Mobile Development Kit Client, app updates are managed by the Mobile Development Kit. The typical flow of the app update process is described below:
- Checking version with Mobile Services: The client checks with Mobile Services for the latest version of the app. If the latest version is the same or older than the currently loaded version, no action is performed.
- Downloading new app bundle: If the latest version available in Mobile Services is newer than the currently loaded app, the client will begin downloading the app bundle from Mobile Services.
pre-updateevent: After the new app bundle is downloaded, the client triggers an
OnWillUpdateevent. In this event, you can perform actions needed for the old app to be unloaded, such as, closing offline store, persisting settings, prompting the user to accept or postpone the update.
- Applying and loading new app bundle: If the
OnWillUpdateevent is not rejected, the client applies and loads the new app bundle. If there is any trouble in loading the new app bundle, the client reverts the app bundle back to previous working version.
- Triggering post-update event: After the new app bundle is applied and loaded, the client triggers an
- In this event, you can perform actions needed for the new app bundle to work, such as re-opening and initializing the offline store.
OnDidUpdatefails or is rejected, the client reverts the app bundle back to previous working version and then triggers another
OnDidUpdateevent for the older app bundle.
- Completing app update: The new app is now loaded and ready to be used.
- The client begins this process again when the conditions for the app update process are met.
Conditions for App Update¶
In the Mobile Development Kit Client, the app update process is triggered in the following conditions:
- After the client is launched and user has entered the passcode
- After the client is resumed from the background and user has entered the passcode
- While the client is running in the foreground, the app update process is triggered after every 20-25 minutes.
App Update Events¶
This event is triggered when a new version of the app is detected, downloaded, and ready to be applied. This event allows you to:
- Prepare before a new version of the app is applied, such as by closing offline stores, or by persisting or caching unsaved data
- This event accepts a promise return value. If the promise is rejected, the new version of the app is not applied (This event will still be triggered again in the next update cycle).
- If the event handler is not provided, the new version of the app is automatically applied without prompting the users.
- In this event's handler, you can prompt the user to accept or postpone the new version of the app. If the user accepts it, resolve the promise, otherwise reject the promise.
This event is triggered after the new version of the app is applied. This event allows you to:
- Prepare after a new version of the app is applied; such as initializing offline stores.
- The event accepts a promise return value. If the promise is rejected, the app is rolled back to the previous version.