mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-14 02:14:52 +08:00
iOS implementation of getUpdateMetadata
This commit is contained in:
23
CodePush.js
23
CodePush.js
@@ -100,12 +100,16 @@ const getConfiguration = (() => {
|
||||
})();
|
||||
|
||||
async function getCurrentPackage() {
|
||||
const localPackage = await NativeCodePush.getCurrentPackage();
|
||||
if (localPackage) {
|
||||
localPackage.failedInstall = await NativeCodePush.isFailedUpdate(localPackage.packageHash);
|
||||
localPackage.isFirstRun = await NativeCodePush.isFirstRun(localPackage.packageHash);
|
||||
return await getUpdateMetadata(CodePush.UpdateState.LATEST);
|
||||
}
|
||||
|
||||
async function getUpdateMetadata(updateState) {
|
||||
const updateMetadata = await NativeCodePush.getUpdateMetadata(updateState || CodePush.UpdateState.RUNNING);
|
||||
if (updateMetadata) {
|
||||
updateMetadata.failedInstall = await NativeCodePush.isFailedUpdate(updateMetadata.packageHash);
|
||||
updateMetadata.isFirstRun = await NativeCodePush.isFirstRun(updateMetadata.packageHash);
|
||||
}
|
||||
return localPackage;
|
||||
return updateMetadata;
|
||||
}
|
||||
|
||||
function getPromisifiedSdk(requestFetchAdapter, config) {
|
||||
@@ -388,9 +392,11 @@ if (NativeCodePush) {
|
||||
checkForUpdate,
|
||||
getConfiguration,
|
||||
getCurrentPackage,
|
||||
getUpdateMetadata,
|
||||
log,
|
||||
notifyApplicationReady,
|
||||
restartApp,
|
||||
restartApplication: restartApp,
|
||||
setUpTestDependencies,
|
||||
sync,
|
||||
InstallMode: {
|
||||
@@ -409,6 +415,11 @@ if (NativeCodePush) {
|
||||
SYNC_IN_PROGRESS: 7, // There is an ongoing "sync" operation in progress.
|
||||
UNKNOWN_ERROR: -1
|
||||
},
|
||||
UpdateState: {
|
||||
RUNNING: NativeCodePush.codePushUpdateStateRunning,
|
||||
PENDING: NativeCodePush.codePushUpdateStatePending,
|
||||
LATEST: NativeCodePush.codePushUpdateStateLatest
|
||||
},
|
||||
DEFAULT_UPDATE_DIALOG: {
|
||||
appendReleaseDescription: false,
|
||||
descriptionPrefix: " Description: ",
|
||||
@@ -424,4 +435,4 @@ if (NativeCodePush) {
|
||||
log("The CodePush module doesn't appear to be properly installed. Please double-check that everything is setup correctly.");
|
||||
}
|
||||
|
||||
module.exports = CodePush;
|
||||
module.exports = CodePush;
|
||||
Reference in New Issue
Block a user