diff --git a/CodePush.ios.js b/CodePush.ios.js index ffcce89..6599bf6 100644 --- a/CodePush.ios.js +++ b/CodePush.ios.js @@ -6,7 +6,7 @@ var packageMixins = require("./package-mixins")(NativeCodePush); var requestFetchAdapter = require("./request-fetch-adapter.js"); var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager; -function checkForUpdate(deploymentKey) { +function checkForUpdate(deploymentKey = null) { var config; var sdk; @@ -274,12 +274,15 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) }); }; +codePush.installPendingUpdate(); + var CodePush = { checkForUpdate: checkForUpdate, getConfiguration: getConfiguration, getCurrentPackage: getCurrentPackage, log: log, notifyApplicationReady: NativeCodePush.notifyApplicationReady, + restartPendingUpdate: NativeCodePush.restartPendingUpdate, setUpTestDependencies: setUpTestDependencies, sync: sync, InstallMode: { diff --git a/CodePush.m b/CodePush.m index 0be5328..d0eaa5f 100644 --- a/CodePush.m +++ b/CodePush.m @@ -346,14 +346,14 @@ RCT_EXPORT_METHOD(notifyApplicationReady:(RCTPromiseResolveBlock)resolve resolve([NSNull null]); } -// This version of restart app is exposed solely for immediately installed +// This function is exposed solely for immediately installed // update support, and shouldn't be consumed directly by user code. -RCT_EXPORT_METHOD(restartForImmedidateUpdate:(int)rollbackTimeout) +RCT_EXPORT_METHOD(restartImmedidateUpdate:(int)rollbackTimeout) { [self initializeUpdateWithRollbackTimeout:rollbackTimeout needsRestart:YES]; } -RCT_EXPORT_METHOD(restartForPendingUpdate) +RCT_EXPORT_METHOD(restartPendingUpdate) { [self checkForPendingUpdate:YES]; } diff --git a/README.md b/README.md index b357a8a..50bd138 100644 --- a/README.md +++ b/README.md @@ -124,16 +124,16 @@ When you require the `react-native-code-push` module, that object provides the f * [checkForUpdate](#codepushcheckforupdate): Queries the CodePush service for an update against the configured deployment. This method returns a promise which resolves to a `RemotePackage` that can be subsequently downloaded. * [getCurrentPackage](#codepushgetcurrentpackage): Gets information about the currently installed package (e.g. description, installation time) -* [notifyApplicationReady](#codepushnotifyapplicationready): Notifies the CodePush runtime that an installed update is considered successful. This is an optional API, but is useful when you want to expicitly enable "rollback protection" in the event that an exception occurs in any code that you've deployed to production +* [notifyApplicationReady](#codepushnotifyapplicationready): Notifies the CodePush runtime that an installed update is considered successful. This is an optional API, but is useful when you want to expicitly enable "rollback protection" in the event that an exception occurs in any code that you've deployed to production. * [sync](#codepushsync): Allows checking for an update, downloading it and installing it, all with a single call. Unless you need custom UI and/or behavior, we recommend most developers to use this method when integrating CodePush into their apps #### codePush.checkForUpdate ```javascript -codePush.checkForUpdate(deploymentKey: String): Promise; +codePush.checkForUpdate(deploymentKey: String = null): Promise; ``` -Queries the CodePush service for an update from the deployment configured in your `Info.plist` file, or specified using the optional `deploymentKey` parameter. This method returns a promise which resolves to a `RemotePackage` that can be subsequently downloaded. +Queries the CodePush service for an update using the deployment configured either in your `Info.plist` file or specified using the optional `deploymentKey` parameter. This method returns a promise which resolves to a `RemotePackage` that can be subsequently downloaded. `checkForUpdate` returns a Promise that resolves to one of two values: diff --git a/package-mixins.js b/package-mixins.js index 2d34046..6416bae 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -40,12 +40,8 @@ module.exports = (NativeCodePush) => { .then(function() { updateInstalledCallback && updateInstalledCallback(); if (installMode == NativeCodePush.codePushInstallModeImmediate) { - NativeCodePush.restartForImmedidateUpdate(rollbackTimeout); - } else { - this.restart = function () { - NaviteCodePush.restartForPendingUpdate(); - } - } + NativeCodePush.restartImmedidateUpdate(rollbackTimeout); + }; }); } };