This repository was archived by the owner on May 20, 2025. It is now read-only.
CodePush.sync() API method #22
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
This provides a simplified and opinionated one-line experience to CodePush-ifying an app. The CodePush.sync() method allows automating the act of checking for an update, downloading it and then subsequently applying it, all while also supporting ignoring previously failed updates, respecting mandatory updates and displaying a standard user confirmation dialog when updates are available.
The method takes an optional options object that can be used to customize the strings used when displaying the user dialog, as well as the rollback timeout.
It returns a Promise that will be resolved with a SyncStatus code, that indicates why the sync succeeded:
0 - No update was available, so the running app is up to do
1 - The app had an optional update, but the end-user chose to ignore it
2 - The app had an optional or mandatory update and the user accepted it
If a failure occurs at any point during the sync, the returned Promise will be rejected with the error reason.
I'll update the docs in a subsequent PR, but I just wanted to get this change out since the respective Cordova change is in review.