mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-19 19:39:54 +08:00
Adding deploymentKey param
This commit is contained in:
@@ -6,13 +6,21 @@ var packageMixins = require("./package-mixins")(NativeCodePush);
|
||||
var requestFetchAdapter = require("./request-fetch-adapter.js");
|
||||
var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager;
|
||||
|
||||
function checkForUpdate() {
|
||||
function checkForUpdate(deploymentKey) {
|
||||
var config;
|
||||
var sdk;
|
||||
|
||||
return getConfiguration()
|
||||
.then((configResult) => {
|
||||
config = configResult;
|
||||
|
||||
// If a deployment key was explicitly provided,
|
||||
// then let's override the one we retrieved
|
||||
// from the native-side of the app.
|
||||
if (deploymentKey) {
|
||||
config.deploymentKey = deploymentKey;
|
||||
}
|
||||
|
||||
return getSdk();
|
||||
})
|
||||
.then((sdkResult) => {
|
||||
@@ -51,12 +59,10 @@ function checkForUpdate() {
|
||||
});
|
||||
}
|
||||
|
||||
var isConfigValid = true;
|
||||
|
||||
var getConfiguration = (() => {
|
||||
var config;
|
||||
return function getConfiguration() {
|
||||
if (config && isConfigValid) {
|
||||
if (config) {
|
||||
return Promise.resolve(config);
|
||||
} else if (testConfig) {
|
||||
return Promise.resolve(testConfig);
|
||||
@@ -64,7 +70,6 @@ var getConfiguration = (() => {
|
||||
return NativeCodePush.getConfiguration()
|
||||
.then((configuration) => {
|
||||
if (!config) config = configuration;
|
||||
isConfigValid = true;
|
||||
return config;
|
||||
});
|
||||
}
|
||||
@@ -136,6 +141,7 @@ function setUpTestDependencies(providedTestSdk, providedTestConfig, testNativeBr
|
||||
function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) {
|
||||
var syncOptions = {
|
||||
|
||||
deploymentKey: null,
|
||||
ignoreFailedUpdates: true,
|
||||
installMode: CodePush.InstallMode.ON_NEXT_RESTART,
|
||||
rollbackTimeout: 0,
|
||||
@@ -191,7 +197,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
syncStatusChangeCallback(CodePush.SyncStatus.CHECKING_FOR_UPDATE);
|
||||
checkForUpdate()
|
||||
checkForUpdate(syncOptions.deploymentKey)
|
||||
.then((remotePackage) => {
|
||||
var doDownloadAndInstall = () => {
|
||||
syncStatusChangeCallback(CodePush.SyncStatus.DOWNLOADING_PACKAGE);
|
||||
|
||||
Reference in New Issue
Block a user