react-native-code-push
Advanced tools
Comparing version 1.10.5-beta to 1.10.6-beta
@@ -12,3 +12,3 @@ import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk"; | ||
* Before we ask the server if an update exists, we | ||
* need to retrieve three pieces of information from the | ||
* need to retrieve three pieces of information from the | ||
* native side: deployment key, app version (e.g. 1.0.1) | ||
@@ -21,3 +21,3 @@ * and the hash of the currently running update (if there is one). | ||
const nativeConfig = await getConfiguration(); | ||
/* | ||
@@ -35,3 +35,3 @@ * If a deployment key was explicitly provided, | ||
const localPackage = await module.exports.getCurrentPackage(); | ||
/* | ||
@@ -54,5 +54,5 @@ * If the app has a previously installed update, and that update | ||
} | ||
const update = await sdk.queryUpdateWithCurrentPackage(queryPackage); | ||
/* | ||
@@ -76,4 +76,4 @@ * There are four cases where checkForUpdate will resolve to null: | ||
*/ | ||
if (!update || update.updateAppVersion || | ||
localPackage && (update.packageHash === localPackage.packageHash) || | ||
if (!update || update.updateAppVersion || | ||
localPackage && (update.packageHash === localPackage.packageHash) || | ||
(!localPackage || localPackage._isDebugOnly) && config.packageHash === update.packageHash) { | ||
@@ -83,3 +83,3 @@ if (update && update.updateAppVersion) { | ||
} | ||
return null; | ||
@@ -102,3 +102,3 @@ } else { | ||
} else { | ||
config = await NativeCodePush.getConfiguration(); | ||
config = await NativeCodePush.getConfiguration(); | ||
return config; | ||
@@ -133,3 +133,3 @@ } | ||
} | ||
}); | ||
}); | ||
}); | ||
@@ -146,3 +146,3 @@ }; | ||
} | ||
}); | ||
}); | ||
}); | ||
@@ -159,3 +159,3 @@ }; | ||
} | ||
}); | ||
}); | ||
}); | ||
@@ -172,3 +172,3 @@ }; | ||
// This ensures that notifyApplicationReadyInternal is only called once | ||
// This ensures that notifyApplicationReadyInternal is only called once | ||
// in the lifetime of this module instance. | ||
@@ -181,3 +181,3 @@ const notifyApplicationReady = (() => { | ||
} | ||
return notifyApplicationReadyPromise; | ||
@@ -188,3 +188,3 @@ }; | ||
async function notifyApplicationReadyInternal() { | ||
await NativeCodePush.notifyApplicationReady(); | ||
await NativeCodePush.notifyApplicationReady(); | ||
const statusReport = await NativeCodePush.getNewStatusReport(); | ||
@@ -224,3 +224,3 @@ if (statusReport) { | ||
const setSyncCompleted = () => { syncInProgress = false; }; | ||
return (options = {}, syncStatusChangeCallback, downloadProgressCallback) => { | ||
@@ -232,4 +232,4 @@ if (syncInProgress) { | ||
return Promise.resolve(CodePush.SyncStatus.SYNC_IN_PROGRESS); | ||
} | ||
} | ||
syncInProgress = true; | ||
@@ -248,3 +248,3 @@ const syncPromise = syncInternal(options, syncStatusChangeCallback, downloadProgressCallback); | ||
* incorporating the check, download and installation of an update. | ||
* | ||
* | ||
* It simply composes the existing API methods together and adds additional | ||
@@ -264,5 +264,5 @@ * support for respecting mandatory updates, ignoring previously failed | ||
updateDialog: null, | ||
...options | ||
...options | ||
}; | ||
syncStatusChangeCallback = typeof syncStatusChangeCallback === "function" | ||
@@ -291,3 +291,3 @@ ? syncStatusChangeCallback | ||
case CodePush.SyncStatus.UPDATE_INSTALLED: | ||
/* | ||
/* | ||
* If the install mode is IMMEDIATE, this will not get returned as the | ||
@@ -311,22 +311,16 @@ * app will be restarted to a new Javascript context. | ||
}; | ||
downloadProgressCallback = typeof downloadProgressCallback === "function" | ||
? downloadProgressCallback | ||
: (downloadProgress) => { | ||
log(`Expecting ${downloadProgress.totalBytes} bytes, received ${downloadProgress.receivedBytes} bytes.`); | ||
}; | ||
try { | ||
await CodePush.notifyApplicationReady(); | ||
syncStatusChangeCallback(CodePush.SyncStatus.CHECKING_FOR_UPDATE); | ||
const remotePackage = await checkForUpdate(syncOptions.deploymentKey); | ||
const doDownloadAndInstall = async () => { | ||
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); | ||
@@ -336,6 +330,6 @@ await localPackage.install(resolvedInstallMode, syncOptions.minimumBackgroundDuration, () => { | ||
}); | ||
return CodePush.SyncStatus.UPDATE_INSTALLED; | ||
}; | ||
const updateShouldBeIgnored = remotePackage && (remotePackage.failedInstall && syncOptions.ignoreFailedUpdates); | ||
@@ -346,3 +340,3 @@ if (!remotePackage || updateShouldBeIgnored) { | ||
} | ||
syncStatusChangeCallback(CodePush.SyncStatus.UP_TO_DATE); | ||
@@ -358,12 +352,12 @@ return CodePush.SyncStatus.UP_TO_DATE; | ||
} | ||
return await new Promise((resolve, reject) => { | ||
return await new Promise((resolve, reject) => { | ||
let message = null; | ||
const dialogButtons = [{ | ||
text: null, | ||
onPress: async () => { | ||
onPress: async () => { | ||
resolve(await doDownloadAndInstall()); | ||
} | ||
}]; | ||
if (remotePackage.isMandatory) { | ||
@@ -374,5 +368,5 @@ message = syncOptions.updateDialog.mandatoryUpdateMessage; | ||
message = syncOptions.updateDialog.optionalUpdateMessage; | ||
dialogButtons[0].text = syncOptions.updateDialog.optionalInstallButtonLabel; | ||
dialogButtons[0].text = syncOptions.updateDialog.optionalInstallButtonLabel; | ||
// Since this is an optional update, add another button | ||
// to allow the end-user to ignore it | ||
// to allow the end-user to ignore it | ||
dialogButtons.push({ | ||
@@ -386,9 +380,9 @@ text: syncOptions.updateDialog.optionalIgnoreButtonLabel, | ||
} | ||
// If the update has a description, and the developer | ||
// explicitly chose to display it, then set that as the message | ||
if (syncOptions.updateDialog.appendReleaseDescription && remotePackage.description) { | ||
message += `${syncOptions.updateDialog.descriptionPrefix} ${remotePackage.description}`; | ||
message += `${syncOptions.updateDialog.descriptionPrefix} ${remotePackage.description}`; | ||
} | ||
syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION); | ||
@@ -402,5 +396,5 @@ Alert.alert(syncOptions.updateDialog.title, message, dialogButtons); | ||
syncStatusChangeCallback(CodePush.SyncStatus.UNKNOWN_ERROR); | ||
log(error.message); | ||
log(error.message); | ||
throw error; | ||
} | ||
} | ||
}; | ||
@@ -410,5 +404,5 @@ | ||
// If the "NativeCodePush" variable isn't defined, then | ||
// If the "NativeCodePush" variable isn't defined, then | ||
// the app didn't properly install the native module, | ||
// and therefore, it doesn't make sense initializing | ||
// and therefore, it doesn't make sense initializing | ||
// the JS interface when it wouldn't work anyways. | ||
@@ -415,0 +409,0 @@ if (NativeCodePush) { |
@@ -17,3 +17,3 @@ import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk"; | ||
if (downloadProgressCallback) { | ||
// Use event subscription to obtain download progress. | ||
// Use event subscription to obtain download progress. | ||
downloadProgressSubscription = DeviceEventEmitter.addListener( | ||
@@ -24,7 +24,7 @@ "CodePushDownloadProgress", | ||
} | ||
// Use the downloaded package info. Native code will save the package info | ||
// so that the client knows what the current package version is. | ||
try { | ||
const downloadedPackage = await NativeCodePush.downloadUpdate(this); | ||
try { | ||
const downloadedPackage = await NativeCodePush.downloadUpdate(this, !!downloadProgressCallback); | ||
reportStatusDownload && reportStatusDownload(this); | ||
@@ -36,3 +36,3 @@ return { ...downloadedPackage, ...local }; | ||
}, | ||
isPending: false // A remote package could never be in a pending state | ||
@@ -53,3 +53,3 @@ }; | ||
}, | ||
isPending: false // A local package wouldn't be pending until it was installed | ||
@@ -56,0 +56,0 @@ }; |
{ | ||
"name": "react-native-code-push", | ||
"version": "1.10.5-beta", | ||
"version": "1.10.6-beta", | ||
"description": "React Native plugin for the CodePush service", | ||
@@ -5,0 +5,0 @@ "main": "CodePush.js", |
@@ -41,4 +41,4 @@ # React Native Module for CodePush | ||
- iOS | ||
- Android | ||
- iOS (7+) | ||
- Android (4.1+) | ||
@@ -45,0 +45,0 @@ We try our best to maintain backwards compatability of our plugin with previous versions of React Native, but due to the nature of the platform, and the existence of breaking changes between releases, it is possible that you need to use a specific version of the CodePush plugin in order to support the exact version of React Native you are using. The following table outlines which CodePush plugin versions officially support the respective React Native versions: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
763389
2597