diff --git a/CodePush.ios.js b/CodePush.ios.js index e459f1301..2c5d5470e 100644 --- a/CodePush.ios.js +++ b/CodePush.ios.js @@ -1,6 +1,5 @@ 'use strict'; -var extend = require("extend"); var NativeCodePush = require("react-native").NativeModules.CodePush; var requestFetchAdapter = require("./request-fetch-adapter.js"); var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager; @@ -103,7 +102,7 @@ function checkForUpdate() { return resolve(null); } - update = extend(update, packageMixins.remote); + update = Object.assign(update, packageMixins.remote); NativeCodePush.isFailedUpdate(update.packageHash) .then((isFailedHash) => { @@ -210,7 +209,13 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) resolve(CodePush.SyncStatus.UP_TO_DATE); } else if (syncOptions.updateDialog) { - syncOptions.updateDialog = Object.assign(CodePush.DEFAULT_UPDATE_DIALOG, syncOptions.updateDialog); + // updateDialog supports any truthy value (e.g. true, "goo", 12), + // but we should treat a non-object value as just the default dialog + if (typeof syncOptions.updateDialog !== "object") { + syncOptions.updateDialog = CodePush.DEFAULT_UPDATE_DIALOG; + } else { + syncOptions.updateDialog = Object.assign({}, CodePush.DEFAULT_UPDATE_DIALOG, syncOptions.updateDialog); + } var message = null; var dialogButtons = [ @@ -233,7 +238,10 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) // to allow the end-user to ignore it dialogButtons.push({ text: syncOptions.updateDialog.optionalIgnoreButtonLabel, - onPress: () => resolve(CodePush.SyncStatus.UPDATE_IGNORED) + onPress: () => { + syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_IGNORED); + resolve(CodePush.SyncStatus.UPDATE_IGNORED); + } }); } @@ -244,7 +252,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) } syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION); - AlertIOS.alert(syncOptions.updateTitle, message, dialogButtons); + AlertIOS.alert(syncOptions.updateDialog.title, message, dialogButtons); } else { doDownloadAndInstall(); } @@ -288,8 +296,8 @@ var CodePush = { optionalIgnoreButtonLabel: "Ignore", optionalInstallButtonLabel: "Install", optionalUpdateMessage: "An update is available. Would you like to install it?", - updateTitle: "Update available", + title: "Update available" } }; -module.exports = CodePush; +module.exports = CodePush; \ No newline at end of file diff --git a/README.md b/README.md index 08c1dadc0..5948d8b73 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,7 @@ The method accepts an options object that allows you to customize numerous aspec * __optionalIgnoreButtonLabel__ (String) - The text to use for the button the end-user can press in order to ignore an optional update that is available. Defaults to `"Ignore"`. * __optionalInstallButtonLabel__ (String) - The text to use for the button the end-user can press in order to install an optional update. Defaults to `"Install"`. * __optionalUpdateMessage__ (String) - The text used as the body of an update notification, when the update is optional. Defaults to `"An update is available. Would you like to install it?"`. - * __updateTitle__ (String) - The text used as the header of an update notification that is displayed to the end-user. Defaults to `"Update available"`. + * __title__ (String) - The text used as the header of an update notification that is displayed to the end-user. Defaults to `"Update available"`. In addition, the method also recieves two function arguments which serve as event handlers which are called at various points in the sync process: diff --git a/package-mixins.js b/package-mixins.js index a098c15f8..aa0f3de3c 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -1,4 +1,3 @@ -var extend = require("extend"); var { NativeAppEventEmitter } = require("react-native"); module.exports = (NativeCodePush) => { @@ -25,7 +24,7 @@ module.exports = (NativeCodePush) => { return NativeCodePush.downloadUpdate(this) .then((downloadedPackage) => { downloadProgressSubscription && downloadProgressSubscription.remove(); - return extend({}, downloadedPackage, local); + return Object.assign({}, downloadedPackage, local); }) .catch((error) => { downloadProgressSubscription && downloadProgressSubscription.remove(); diff --git a/package.json b/package.json index 4f874e53a..46ac764a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-code-push", - "version": "1.2.0-beta", + "version": "1.2.1-beta", "description": "React Native plugin for the CodePush service", "main": "CodePush.ios.js", "homepage": "https://microsoft.github.io/code-push", @@ -16,8 +16,7 @@ "url": "https://github.com/Microsoft/react-native-code-push" }, "dependencies": { - "code-push": "^1.1.1-beta", - "extend": "3.0.0" + "code-push": "^1.1.1-beta" }, "devDependencies": { "react-native": "0.11.4"