Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit e1717dd

Browse files
committed
revert
1 parent 0225ca4 commit e1717dd

File tree

1 file changed

+47
-37
lines changed

1 file changed

+47
-37
lines changed

CodePush.js

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -373,42 +373,52 @@ async function syncInternal(options = {}, syncStatusChangeCallback, downloadProg
373373
}
374374
};
375375

376-
const CodePush = {
377-
AcquisitionSdk: Sdk,
378-
checkForUpdate,
379-
getConfiguration,
380-
getCurrentPackage,
381-
log,
382-
notifyApplicationReady,
383-
restartApp,
384-
setUpTestDependencies,
385-
sync,
386-
InstallMode: {
387-
IMMEDIATE: NativeCodePush.codePushInstallModeImmediate, // Restart the app immediately
388-
ON_NEXT_RESTART: NativeCodePush.codePushInstallModeOnNextRestart, // Don't artificially restart the app. Allow the update to be "picked up" on the next app restart
389-
ON_NEXT_RESUME: NativeCodePush.codePushInstallModeOnNextResume // Restart the app the next time it is resumed from the background
390-
},
391-
SyncStatus: {
392-
CHECKING_FOR_UPDATE: 0,
393-
AWAITING_USER_ACTION: 1,
394-
DOWNLOADING_PACKAGE: 2,
395-
INSTALLING_UPDATE: 3,
396-
UP_TO_DATE: 4, // The running app is up-to-date
397-
UPDATE_IGNORED: 5, // The app had an optional update and the end-user chose to ignore it
398-
UPDATE_INSTALLED: 6, // The app had an optional/mandatory update that was successfully downloaded and is about to be installed.
399-
SYNC_IN_PROGRESS: 7, // There is an ongoing "sync" operation in progress.
400-
UNKNOWN_ERROR: -1
401-
},
402-
DEFAULT_UPDATE_DIALOG: {
403-
appendReleaseDescription: false,
404-
descriptionPrefix: " Description: ",
405-
mandatoryContinueButtonLabel: "Continue",
406-
mandatoryUpdateMessage: "An update is available that must be installed.",
407-
optionalIgnoreButtonLabel: "Ignore",
408-
optionalInstallButtonLabel: "Install",
409-
optionalUpdateMessage: "An update is available. Would you like to install it?",
410-
title: "Update available"
411-
}
412-
};
376+
let CodePush;
377+
378+
// If the "NativeCodePush" variable isn't defined, then
379+
// the app didn't properly install the native module,
380+
// and therefore, it doesn't make sense initializing
381+
// the JS interface when it wouldn't work anyways.
382+
if (NativeCodePush) {
383+
CodePush = {
384+
AcquisitionSdk: Sdk,
385+
checkForUpdate,
386+
getConfiguration,
387+
getCurrentPackage,
388+
log,
389+
notifyApplicationReady,
390+
restartApp,
391+
setUpTestDependencies,
392+
sync,
393+
InstallMode: {
394+
IMMEDIATE: NativeCodePush.codePushInstallModeImmediate, // Restart the app immediately
395+
ON_NEXT_RESTART: NativeCodePush.codePushInstallModeOnNextRestart, // Don't artificially restart the app. Allow the update to be "picked up" on the next app restart
396+
ON_NEXT_RESUME: NativeCodePush.codePushInstallModeOnNextResume // Restart the app the next time it is resumed from the background
397+
},
398+
SyncStatus: {
399+
CHECKING_FOR_UPDATE: 0,
400+
AWAITING_USER_ACTION: 1,
401+
DOWNLOADING_PACKAGE: 2,
402+
INSTALLING_UPDATE: 3,
403+
UP_TO_DATE: 4, // The running app is up-to-date
404+
UPDATE_IGNORED: 5, // The app had an optional update and the end-user chose to ignore it
405+
UPDATE_INSTALLED: 6, // The app had an optional/mandatory update that was successfully downloaded and is about to be installed.
406+
SYNC_IN_PROGRESS: 7, // There is an ongoing "sync" operation in progress.
407+
UNKNOWN_ERROR: -1
408+
},
409+
DEFAULT_UPDATE_DIALOG: {
410+
appendReleaseDescription: false,
411+
descriptionPrefix: " Description: ",
412+
mandatoryContinueButtonLabel: "Continue",
413+
mandatoryUpdateMessage: "An update is available that must be installed.",
414+
optionalIgnoreButtonLabel: "Ignore",
415+
optionalInstallButtonLabel: "Install",
416+
optionalUpdateMessage: "An update is available. Would you like to install it?",
417+
title: "Update available"
418+
}
419+
}
420+
} else {
421+
log("The CodePush module doesn't appear to be properly installed. Please double-check that everything is setup correctly.");
422+
}
413423

414424
module.exports = CodePush;

0 commit comments

Comments
 (0)