mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-14 02:14:52 +08:00
mandatoryInstallMode
This commit is contained in:
15
CodePush.js
15
CodePush.js
@@ -227,21 +227,21 @@ const sync = (() => {
|
||||
|
||||
/*
|
||||
* The syncInternal method provides a simple, one-line experience for
|
||||
* incorporating the check, download and application of an update.
|
||||
* incorporating the check, download and installation of an update.
|
||||
*
|
||||
* It simply composes the existing API methods together and adds additional
|
||||
* support for respecting mandatory updates, ignoring previously failed
|
||||
* releases, and displaying a standard confirmation UI to the end-user
|
||||
* when an update is available.
|
||||
*/
|
||||
async function syncInternal(options = {}, syncStatusChangeCallback, downloadProgressCallback) {
|
||||
async function syncInternal(options = {}, syncStatusChangeCallback, downloadProgressCallback) {
|
||||
let resolvedInstallMode;
|
||||
const syncOptions = {
|
||||
|
||||
deploymentKey: null,
|
||||
ignoreFailedUpdates: true,
|
||||
installMode: CodePush.InstallMode.ON_NEXT_RESTART,
|
||||
mandatoryInstallMode: CodePush.InstallMode.IMMEDIATE,
|
||||
updateDialog: null,
|
||||
|
||||
...options
|
||||
};
|
||||
|
||||
@@ -272,7 +272,7 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
|
||||
* If the install mode is IMMEDIATE, this will not get returned as the
|
||||
* app will be restarted to a new Javascript context.
|
||||
*/
|
||||
if (syncOptions.installMode == CodePush.InstallMode.ON_NEXT_RESTART) {
|
||||
if (resolvedInstallMode == CodePush.InstallMode.ON_NEXT_RESTART) {
|
||||
log("Update is installed and will be run on the next app restart.");
|
||||
} else {
|
||||
log("Update is installed and will be run when the app next resumes.");
|
||||
@@ -300,8 +300,11 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
|
||||
syncStatusChangeCallback(CodePush.SyncStatus.DOWNLOADING_PACKAGE);
|
||||
const localPackage = await remotePackage.download(downloadProgressCallback);
|
||||
|
||||
// Determine the correct install mode based on whether the update is mandatory or not.
|
||||
resolvedInstallMode = localPackage.isMandatory ? syncOptions.mandatoryInstallMode : syncOptions.installMode;
|
||||
|
||||
syncStatusChangeCallback(CodePush.SyncStatus.INSTALLING_UPDATE);
|
||||
await localPackage.install(syncOptions.installMode, () => {
|
||||
await localPackage.install(resolvedInstallMode, () => {
|
||||
syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_INSTALLED);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user