New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-code-push

Package Overview
Dependencies
Maintainers
2
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-code-push - npm Package Compare versions

Comparing version 1.5.2-beta to 1.5.3-beta

368

CodePush.js

@@ -1,13 +0,10 @@

'use strict';
import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk";
import { Alert } from "./AlertAdapter";
import requestFetchAdapter from "./request-fetch-adapter";
import semver from "semver";
var { Alert } = require("./AlertAdapter");
var NativeCodePush = require("react-native").NativeModules.CodePush;
var PackageMixins = require("./package-mixins")(NativeCodePush);
var requestFetchAdapter = require("./request-fetch-adapter.js");
var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager;
var semver = require("semver");
let NativeCodePush = require("react-native").NativeModules.CodePush;
const PackageMixins = require("./package-mixins")(NativeCodePush);
function checkForUpdate(deploymentKey = null) {
var config, sdk;
async function checkForUpdate(deploymentKey = null) {
/*

@@ -22,87 +19,62 @@ * Before we ask the server if an update exists, we

*/
return getConfiguration()
.then((configResult) => {
/*
* If a deployment key was explicitly provided,
* then let's override the one we retrieved
* from the native-side of the app. This allows
* dynamically "redirecting" end-users at different
* deployments (e.g. an early access deployment for insiders).
*/
if (deploymentKey) {
config = Object.assign({}, configResult, { deploymentKey });
} else {
config = configResult;
}
sdk = new module.exports.AcquisitionSdk(requestFetchAdapter, config);
// Allow dynamic overwrite of function. This is only to be used for tests.
return module.exports.getCurrentPackage();
})
.then((localPackage) => {
var queryPackage = { appVersion: config.appVersion };
/*
* If the app has a previously installed update, and that update
* was targetted at the same app version that is currently running,
* then we want to use its package hash to determine whether a new
* release has been made on the server. Otherwise, we only need
* to send the app version to the server, since we are interested
* in any updates for current app store version, regardless of hash.
*/
if (localPackage && localPackage.appVersion && semver.compare(localPackage.appVersion, config.appVersion) === 0) {
queryPackage = localPackage;
}
return new Promise((resolve, reject) => {
sdk.queryUpdateWithCurrentPackage(queryPackage, (err, update) => {
if (err) {
return reject(err);
}
/*
* There are three cases where checkForUpdate will resolve to null:
* ----------------------------------------------------------------
* 1) The server said there isn't an update. This is the most common case.
* 2) The server said there is an update but it requires a newer binary version.
* This would occur when end-users are running an older app store version than
* is available, and CodePush is making sure they don't get an update that
* potentially wouldn't be compatible with what they are running.
* 3) The server said there is an update, but the update's hash is the same as
* the currently running update. This should _never_ happen, unless there is a
* bug in the server, but we're adding this check just to double-check that the
* client app is resilient to a potential issue with the update check.
*/
if (!update || update.updateAppVersion || (update.packageHash === localPackage.packageHash)) {
return resolve(null);
}
update = Object.assign(update, PackageMixins.remote);
NativeCodePush.isFailedUpdate(update.packageHash)
.then((isFailedHash) => {
update.failedInstall = isFailedHash;
resolve(update);
})
.catch(reject)
.done();
})
});
});
const nativeConfig = await getConfiguration();
/*
* If a deployment key was explicitly provided,
* then let's override the one we retrieved
* from the native-side of the app. This allows
* dynamically "redirecting" end-users at different
* deployments (e.g. an early access deployment for insiders).
*/
const config = deploymentKey ? { ...nativeConfig, ...{ deploymentKey } } : nativeConfig;
const sdk = getPromisifiedSdk(requestFetchAdapter, config);
// Use dynamically overridden getCurrentPackage() during tests.
const localPackage = await module.exports.getCurrentPackage();
/*
* If the app has a previously installed update, and that update
* was targetted at the same app version that is currently running,
* then we want to use its package hash to determine whether a new
* release has been made on the server. Otherwise, we only need
* to send the app version to the server, since we are interested
* in any updates for current app store version, regardless of hash.
*/
const queryPackage = localPackage && localPackage.appVersion && semver.compare(localPackage.appVersion, config.appVersion) === 0
? localPackage
: { appVersion: config.appVersion };
const update = await sdk.queryUpdateWithCurrentPackage(queryPackage);
/*
* There are three cases where checkForUpdate will resolve to null:
* ----------------------------------------------------------------
* 1) The server said there isn't an update. This is the most common case.
* 2) The server said there is an update but it requires a newer binary version.
* This would occur when end-users are running an older app store version than
* is available, and CodePush is making sure they don't get an update that
* potentially wouldn't be compatible with what they are running.
* 3) The server said there is an update, but the update's hash is the same as
* the currently running update. This should _never_ happen, unless there is a
* bug in the server, but we're adding this check just to double-check that the
* client app is resilient to a potential issue with the update check.
*/
if (!update || update.updateAppVersion || (update.packageHash === localPackage.packageHash)) {
return null;
} else {
const remotePackage = { ...update, ...PackageMixins.remote };
remotePackage.failedInstall = await NativeCodePush.isFailedUpdate(remotePackage.packageHash);
return remotePackage;
}
}
var getConfiguration = (() => {
var config;
return function getConfiguration() {
const getConfiguration = (() => {
let config;
return async function getConfiguration() {
if (config) {
return Promise.resolve(config);
return config;
} else if (testConfig) {
return Promise.resolve(testConfig);
return testConfig;
} else {
return NativeCodePush.getConfiguration()
.then((configuration) => {
if (!config) config = configuration;
return config;
});
config = await NativeCodePush.getConfiguration();
return config;
}

@@ -112,23 +84,27 @@ }

function getCurrentPackage() {
return new Promise((resolve, reject) => {
var localPackage;
NativeCodePush.getCurrentPackage()
.then((currentPackage) => {
localPackage = currentPackage;
return NativeCodePush.isFailedUpdate(currentPackage.packageHash);
})
.then((failedUpdate) => {
localPackage.failedInstall = failedUpdate;
return NativeCodePush.isFirstRun(localPackage.packageHash);
})
.then((isFirstRun) => {
localPackage.isFirstRun = isFirstRun;
resolve(localPackage);
})
.catch(reject)
.done();
});
async function getCurrentPackage() {
const localPackage = await NativeCodePush.getCurrentPackage();
localPackage.failedInstall = await NativeCodePush.isFailedUpdate(localPackage.packageHash);
localPackage.isFirstRun = await NativeCodePush.isFirstRun(localPackage.packageHash);
return localPackage;
}
function getPromisifiedSdk(requestFetchAdapter, config) {
// Use dynamically overridden AcquisitionSdk during tests.
const sdk = new module.exports.AcquisitionSdk(requestFetchAdapter, config);
sdk.queryUpdateWithCurrentPackage = (queryPackage) => {
return new Promise((resolve, reject) => {
module.exports.AcquisitionSdk.prototype.queryUpdateWithCurrentPackage.call(sdk, queryPackage, (err, update) => {
if (err) {
reject(err);
} else {
resolve(update);
}
});
});
};
return sdk;
}
/* Logs messages to console with the [CodePush] prefix */

@@ -139,2 +115,6 @@ function log(message) {

function restartApp(onlyIfUpdateIsPending = false) {
NativeCodePush.restartApp(onlyIfUpdateIsPending);
}
var testConfig;

@@ -158,4 +138,4 @@

*/
function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) {
var syncOptions = {
async function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) {
const syncOptions = {

@@ -172,3 +152,3 @@ deploymentKey: null,

? syncStatusChangeCallback
: function(syncStatus) {
: (syncStatus) => {
switch(syncStatus) {

@@ -212,101 +192,91 @@ case CodePush.SyncStatus.CHECKING_FOR_UPDATE:

? downloadProgressCallback
: function(downloadProgress) {
: (downloadProgress) => {
log(`Expecting ${downloadProgress.totalBytes} bytes, received ${downloadProgress.receivedBytes} bytes.`);
};
return new Promise((resolve, reject) => {
var rejectPromise = (error) => {
syncStatusChangeCallback(CodePush.SyncStatus.UNKNOWN_ERROR);
log(error.message);
reject(error);
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);
syncStatusChangeCallback(CodePush.SyncStatus.INSTALLING_UPDATE);
await localPackage.install(syncOptions.installMode, () => {
syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_INSTALLED);
});
return CodePush.SyncStatus.UPDATE_INSTALLED;
};
CodePush.notifyApplicationReady()
.then(() => {
syncStatusChangeCallback(CodePush.SyncStatus.CHECKING_FOR_UPDATE);
return checkForUpdate(syncOptions.deploymentKey);
})
.then((remotePackage) => {
var doDownloadAndInstall = () => {
syncStatusChangeCallback(CodePush.SyncStatus.DOWNLOADING_PACKAGE);
remotePackage.download(downloadProgressCallback)
.then((localPackage) => {
syncStatusChangeCallback(CodePush.SyncStatus.INSTALLING_UPDATE);
return localPackage.install(syncOptions.installMode, () => {
syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_INSTALLED);
resolve(CodePush.SyncStatus.UPDATE_INSTALLED);
});
})
.catch(rejectPromise)
.done();
}
if (!remotePackage || (remotePackage.failedInstall && syncOptions.ignoreFailedUpdates)) {
syncStatusChangeCallback(CodePush.SyncStatus.UP_TO_DATE);
return CodePush.SyncStatus.UP_TO_DATE;
} else if (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 = { ...CodePush.DEFAULT_UPDATE_DIALOG, ...syncOptions.updateDialog };
}
if (!remotePackage || (remotePackage.failedInstall && syncOptions.ignoreFailedUpdates)) {
syncStatusChangeCallback(CodePush.SyncStatus.UP_TO_DATE);
resolve(CodePush.SyncStatus.UP_TO_DATE);
}
else if (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);
return await new Promise((resolve, reject) => {
let message = null;
const dialogButtons = [{
text: null,
onPress: async () => {
resolve(await doDownloadAndInstall());
}
var message = null;
var dialogButtons = [
{
text: null,
onPress: () => {
doDownloadAndInstall();
}
}];
if (remotePackage.isMandatory) {
message = syncOptions.updateDialog.mandatoryUpdateMessage;
dialogButtons[0].text = syncOptions.updateDialog.mandatoryContinueButtonLabel;
} else {
message = syncOptions.updateDialog.optionalUpdateMessage;
dialogButtons[0].text = syncOptions.updateDialog.optionalInstallButtonLabel;
// Since this is an optional update, add another button
// to allow the end-user to ignore it
dialogButtons.push({
text: syncOptions.updateDialog.optionalIgnoreButtonLabel,
onPress: () => {
syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_IGNORED);
resolve(CodePush.SyncStatus.UPDATE_IGNORED);
}
];
if (remotePackage.isMandatory) {
message = syncOptions.updateDialog.mandatoryUpdateMessage;
dialogButtons[0].text = syncOptions.updateDialog.mandatoryContinueButtonLabel;
} else {
message = syncOptions.updateDialog.optionalUpdateMessage;
dialogButtons[0].text = syncOptions.updateDialog.optionalInstallButtonLabel;
// Since this is an optional update, add another button
// to allow the end-user to ignore it
dialogButtons.push({
text: syncOptions.updateDialog.optionalIgnoreButtonLabel,
onPress: () => {
syncStatusChangeCallback(CodePush.SyncStatus.UPDATE_IGNORED);
resolve(CodePush.SyncStatus.UPDATE_IGNORED);
}
});
}
// 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}`;
}
syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION);
Alert.alert(syncOptions.updateDialog.title, message, dialogButtons);
} else {
doDownloadAndInstall();
});
}
})
.catch(rejectPromise)
.done();
});
// 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}`;
}
syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION);
Alert.alert(syncOptions.updateDialog.title, message, dialogButtons);
});
} else {
return await doDownloadAndInstall();
}
} catch (error) {
syncStatusChangeCallback(CodePush.SyncStatus.UNKNOWN_ERROR);
log(error.message);
throw error;
}
};
var CodePush = {
const CodePush = {
AcquisitionSdk: Sdk,
checkForUpdate: checkForUpdate,
getConfiguration: getConfiguration,
getCurrentPackage: getCurrentPackage,
log: log,
checkForUpdate,
getConfiguration,
getCurrentPackage,
log,
notifyApplicationReady: NativeCodePush.notifyApplicationReady,
restartApp: NativeCodePush.restartApp,
setUpTestDependencies: setUpTestDependencies,
sync: sync,
restartApp,
setUpTestDependencies,
sync,
InstallMode: {

@@ -339,2 +309,2 @@ IMMEDIATE: NativeCodePush.codePushInstallModeImmediate, // Restart the app immediately

module.exports = CodePush;
module.exports = CodePush;

@@ -8,12 +8,8 @@ import { DeviceEventEmitter } from "react-native";

const remote = {
abortDownload() {
return NativeCodePush.abortDownload(this);
},
download(downloadProgressCallback) {
async download(downloadProgressCallback) {
if (!this.downloadUrl) {
return Promise.reject(new Error("Cannot download an update without a download url"));
throw new Error("Cannot download an update without a download url");
}
var downloadProgressSubscription;
let downloadProgressSubscription;
if (downloadProgressCallback) {

@@ -29,12 +25,8 @@ // Use event subscription to obtain download progress.

// so that the client knows what the current package version is.
return NativeCodePush.downloadUpdate(this)
.then((downloadedPackage) => {
downloadProgressSubscription && downloadProgressSubscription.remove();
return Object.assign({}, downloadedPackage, local);
})
.catch((error) => {
downloadProgressSubscription && downloadProgressSubscription.remove();
// Rethrow the error for subsequent handlers down the promise chain.
throw error;
});
try {
const downloadedPackage = await NativeCodePush.downloadUpdate(this);
return { ...downloadedPackage, ...local };
} finally {
downloadProgressSubscription && downloadProgressSubscription.remove();
}
},

@@ -46,13 +38,11 @@

const local = {
install(installMode = NativeCodePush.codePushInstallModeOnNextRestart, updateInstalledCallback) {
let localPackage = this;
return NativeCodePush.installUpdate(this, installMode)
.then(() => {
updateInstalledCallback && updateInstalledCallback();
if (installMode == NativeCodePush.codePushInstallModeImmediate) {
NativeCodePush.restartApp();
} else {
localPackage.isPending = true; // Mark the package as pending since it hasn't been applied yet
}
});
async install(installMode = NativeCodePush.codePushInstallModeOnNextRestart, updateInstalledCallback) {
const localPackage = this;
await NativeCodePush.installUpdate(this, installMode);
updateInstalledCallback && updateInstalledCallback();
if (installMode == NativeCodePush.codePushInstallModeImmediate) {
NativeCodePush.restartApp(false);
} else {
localPackage.isPending = true; // Mark the package as pending since it hasn't been applied yet
}
},

@@ -59,0 +49,0 @@

{
"name": "react-native-code-push",
"version": "1.5.2-beta",
"version": "1.5.3-beta",
"description": "React Native plugin for the CodePush service",

@@ -5,0 +5,0 @@ "main": "CodePush.js",

@@ -28,2 +28,4 @@ # React Native Plugin for CodePush

In order to ensure that your end users always have a functioning version of your app, the CodePush plugin maintains a copy of the previous update, so that in the event that you accidentally push an update which includes a crash, it can automatically roll back. This way, you can rest assured that your newfound release agility won't result in users becoming blocked before you have a chance to [roll back](http://microsoft.github.io/code-push/docs/cli.html#link-8) on the server. It's a win-win-win!
*Note: Any product changes which touch native code (e.g. modifying your `AppDelegate.m`/`MainActivity.java` file, adding a new plugin) cannot be distributed via CodePush, and therefore, must be updated via the appropriate store(s).*

@@ -196,3 +198,3 @@

```
var CodePush = require("react-native-code-push")
import CodePush from "react-native-code-push";
```

@@ -212,3 +214,3 @@

1. Execute `react-native bundle` (passing the appropriate parameters) in order to generate the updated JS bundle for your app. You can place this file wherever you want via the `--bundle-output` flag, since the exact location isn't relevant for CodePush purposes.
1. Execute `react-native bundle` (passing the appropriate parameters, see example below) in order to generate the updated JS bundle for your app. You can place this file wherever you want via the `--bundle-output` flag, since the exact location isn't relevant for CodePush purposes. It's important, however, that you set `--dev false` so that your JS code is optimized appropriately and any "yellow box" warnings won't be displayed.

@@ -220,3 +222,3 @@ 2. Execute `code-push release <appName> <jsBundleFilePath> <appStoreVersion> --deploymentName <deploymentName>` in order to publish the generated JS bundle to the server. The `<jsBundleFilePath>` parameter should equal the value you provided to the `--bundle-output` flag in step #1. Additionally, the `<appStoreVersion>` parameter should equal the exact app store version (i.e. the semver version end users would see when installing it) you want this CodePush update to target.

```
react-native bundle --platform ios --entry-file index.ios.js --bundle-output codepush.js
react-native bundle --platform ios --entry-file index.ios.js --bundle-output codepush.js --dev false
code-push release MyApp codepush.js 1.0.2

@@ -231,6 +233,10 @@ ```

If you are using the new React Native [assets system](https://facebook.github.io/react-native/docs/images.html#content), as opposed to loading your images from the network and/or platform-specific mechanisms (e.g. iOS asset catalogs), then you can't simply pass your jsbundle to CodePush as demonstrated above. You need to provide your images as well. To do this, simply use the following workflow:
*Note: Android doesn't currently support deploying assets, so you must use the previous release strategy instead.*
1. When calling `react-native bundle`, specify that your assets and JS bundle go into a new "release" folder (you can call this anything, but it shouldn't contain any other files). For example:
If you are using the new React Native [assets system](https://facebook.github.io/react-native/docs/images.html#content), as opposed to loading your images from the network and/or platform-specific mechanisms (e.g. iOS asset catalogs), then you can't simply pass your jsbundle to CodePush as demonstrated above. You **MUST** provide your images as well. To do this, simply use the following workflow:
1. Create a new directory that can be used to organize your app's release assets (i.e. the JS bundle and your images). We recommend calling this directory "release" but it can be named anything. If you create this directory within your project's directory, make sure to add it to your `.gitignore` file, since you don't want it checked into source control.
2. When calling `react-native bundle`, specify that your assets and JS bundle go into the directory you created in #1, and that you want a non-dev build for your respective platform and entry file. For example, assuming you called this directory "release", you could run the following command:
```

@@ -242,5 +248,6 @@ react-native bundle \

--assets-dest ./release
--dev false
```
2. Execute `code-push release`, passing the path to the directory you used in #1 as the "package" parameter (e.g. `code-push release Foo ./release 1.0.0`). The code-push CLI will automatically handle zipping up the contents for you, so don't worry about handling that yourself.
3. Execute `code-push release`, passing the path to the directory you created in #1 as the "package" parameter (e.g. `code-push release Foo ./release 1.0.0`). The code-push CLI will automatically handle zipping up the contents for you, so don't worry about handling that yourself.

@@ -287,5 +294,10 @@ Additionally, the CodePush client supports differential updates, so even though you are releasing your JS bundle and assets on every update, your end users will only actually download the files they need. The service handles this automatically so that you can focus on creating awesome apps and we can worry about optimizing end user downloads.

* `null` if there is no update available.
* A `RemotePackage` instance which represents an available update that can be inspected and/or subsequently downloaded.
1. `null` if there is no update available. This occurs in the following scenarios:
1. The configured deployment doesn't contain any releases, and therefore, nothing to update.
2. The latest release within the configured deployment is targeting a different binary version than what you're currently running (either older or newer).
3. The currently running app already has the latest release from the configured deployment, and therefore, doesn't need it again.
2. A [`RemotePackage`](#remotepackage) instance which represents an available update that can be inspected and/or subsequently downloaded.
Example Usage:

@@ -310,5 +322,5 @@

Retrieves the metadata about the currently installed "package" (e.g. description, installation time). This can be useful for scenarios such as displaying a "what's new?" dialog after an update has been applied.
Retrieves the metadata about the currently installed "package" (e.g. description, installation time). This can be useful for scenarios such as displaying a "what's new?" dialog after an update has been applied or checking whether there is a pending update that is waiting to be applied via a resume or restart.
This method returns a `Promise` which resolves to the `LocalPackage` instance that represents the currently running update.
This method returns a `Promise` which resolves to the [`LocalPackage`](#localpackage) instance that represents the currently running update.

@@ -342,8 +354,11 @@ Example Usage:

```javascript
codePush.restartApp(): void;
codePush.restartApp(onlyIfUpdateIsPending: Boolean = false): void;
```
Immediately restarts the app. If there is an update pending, it will be presented to the end user and the rollback timer (if specified when installing the update) will begin. Otherwise, calling this method simply has the same behavior as the end user killing and restarting the process. This method is for advanced scenarios, and is primarily useful when the following conditions are true:
Immediately restarts the app. If a truthy value is provided to the `onlyIfUpdateIsPending` parameter, then the app will only restart if there is actually a pending update waiting to be applied.
This method is for advanced scenarios, and is primarily useful when the following conditions are true:
1. Your app is specifying an install mode value of `ON_NEXT_RESTART` or `ON_NEXT_RESUME` when calling the `sync` or `LocalPackage.install` methods. This has the effect of not applying your update until the app has been restarted (by either the end user or OS) or resumed, and therefore, the update won't be immediately displayed to the end user .
1. Your app is specifying an install mode value of `ON_NEXT_RESTART` or `ON_NEXT_RESUME` when calling the `sync` or `LocalPackage.install` methods. This has the effect of not applying your update until the app has been restarted (by either the end user or OS) or resumed, and therefore, the update won't be immediately displayed to the end user.
2. You have an app-specific user event (e.g. the end user navigated back to the app's home route) that allows you to apply the update in an unobtrusive way, and potentially gets the update in front of the end user sooner then waiting until the next restart or resume.

@@ -357,7 +372,7 @@

Synchronizes your app's JavaScript bundle and image assets with the latest release to the configured deployment. Unlike the `checkForUpdate` method, which simply checks for the presence of an update, and let's you control what to do next, `sync` handles the update check, download and installation experience for you.
Synchronizes your app's JavaScript bundle and image assets with the latest release to the configured deployment. Unlike the [checkForUpdate](#codepushcheckforupdate) method, which simply checks for the presence of an update, and let's you control what to do next, `sync` handles the update check, download and installation experience for you.
This method provides support for two different (but customizable) "modes" to easily enable apps with different requirements:
1. **Silent mode** *(the default behavior)*, which automatically downloads available updates, and applies them the next time the app restarts. This way, the entire update experience is "silent" to the end user, since they don't see any update prompt and/or "synthetic" app restarts.
1. **Silent mode** *(the default behavior)*, which automatically downloads available updates, and applies them the next time the app restarts (e.g. the OS or end user killed it, or the device was restarted). This way, the entire update experience is "silent" to the end user, since they don't see any update prompt and/or "synthetic" app restarts.

@@ -422,2 +437,12 @@ 2. **Active mode**, which when an update is available, prompts the end user for permission before downloading it, and then immediately applies the update. If an update was released using the `mandatory` flag, the end user would still be notified about the update, but they wouldn't have the choice to ignore it.

codePush.sync({ updateDialog: { title: "An update is available!" } });
// Displaying an update prompt which includes the
// description associated with the CodePush release
codePush.sync({
updateDialog: {
appendReleaseDescription: true,
descriptionPrefix: "\n\nChange log:\n"
},
installMode: codePush.InstallMode.IMMEDIATE
});
```

@@ -453,3 +478,5 @@

* __CodePush.SyncStatus.UP_TO_DATE__ *(4)* - The app is up-to-date with the CodePush server.
* __CodePush.SyncStatus.UPDATE_IGNORED__ *(5)* - The app had an optional update which the end user chose to ignore. (This is only applicable when the `updateDialog` is used)
* __CodePush.SyncStatus.UPDATE_INSTALLED__ *(6)* - The update has been installed and will be run either immediately after the `syncStatusChangedCallback` function returns or the next time the app resumes/restarts, depending on the `InstallMode` specified in `SyncOptions`.

@@ -465,3 +492,4 @@

* [LocalPackage](#localpackage): Represents a downloaded update package that is either already running, or has been installed and is pending an app restart.
* [LocalPackage](#localpackage): Represents a downloaded update that is either already running, or has been installed and is pending an app restart.
* [RemotePackage](#remotepackage): Represents an available update on the CodePush server that hasn't been downloaded yet.

@@ -565,4 +593,10 @@

- __CodePush(String deploymentKey, Activity mainActivity)__ - Creates a new instance of the CodePush runtime, that will be used to query the service for updates via the provided deployment key. The `mainActivity` parameter should always be set to `this` when configuring your `ReactInstanceManager` inside the `MainActivity` class.
- __CodePush(String deploymentKey, Activity mainActivity)__ - Creates a new instance of the CodePush runtime, that will be used to query the service for updates via the provided deployment key. The `mainActivity` parameter should always be set to `this` when configuring your `ReactInstanceManager` inside the `MainActivity` class. This constructor puts the CodePush runtime into "release mode", so if you want to enable debugging behavior, use the following constructor instead.
- __CodePush(String deploymentKey, Activity mainActivity, bool isDebugMode)__ - Equivalent to the previous constructor, but allows you to specify whether you want the CodePush runtime to be in debug mode or not. When using this constructor, the `isDebugMode` parameter should always be set to `BuildConfig.DEBUG` in order to stay synchronized with your build type. When putting CodePush into debug mode, the following behaviors are enabled:
1. Old CodePush updates aren't deleted from storage whenever a new binary is deployed to the emulator/device. This behavior enables you to deploy new binaries, without bumping the version during development, and without continuously getting the same update every time your app calls `sync`.
2. The local cache that the React Native runtime maintains in debug mode is deleted whenever a CodePush update is installed. This ensures that when the app is restarted after an update is applied, you will see the expected changes. As soon as [this PR](https://github.com/facebook/react-native/pull/4738) is merged, we won't need to do this anymore.
##### Methods

@@ -569,0 +603,0 @@

@@ -1,30 +0,31 @@

module.exports.request = function request(verb, url, body, callback) {
module.exports = {
async request(verb, url, body, callback) {
if (typeof body === "function") {
callback = body;
body = null;
callback = body;
body = null;
}
var headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
"Accept": "application/json",
"Content-Type": "application/json"
};
if (body && typeof body === "object") {
body = JSON.stringify(body);
body = JSON.stringify(body);
}
var statusCode;
fetch(url, {
try {
const response = await fetch(url, {
method: verb,
headers: headers,
body: body
}).then(function(response) {
statusCode = response.status;
return response.text();
}).then(function(body) {
callback(null, {statusCode: statusCode, body: body});
}).catch(function(err) {
callback(err);
});
}
});
const statusCode = response.status;
const body = await response.text();
callback(null, { statusCode, body });
} catch (err) {
callback(err);
}
}
};

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc