Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 24d3ef7

Browse files
committed
Adding deploymentKey param
1 parent 8e04d38 commit 24d3ef7

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

CodePush.ios.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@ var packageMixins = require("./package-mixins")(NativeCodePush);
66
var requestFetchAdapter = require("./request-fetch-adapter.js");
77
var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager;
88

9-
function checkForUpdate() {
9+
function checkForUpdate(deploymentKey) {
1010
var config;
1111
var sdk;
1212

1313
return getConfiguration()
1414
.then((configResult) => {
1515
config = configResult;
16+
17+
// If a deployment key was explicitly provided,
18+
// then let's override the one we retrieved
19+
// from the native-side of the app.
20+
if (deploymentKey) {
21+
config.deploymentKey = deploymentKey;
22+
}
23+
1624
return getSdk();
1725
})
1826
.then((sdkResult) => {
@@ -51,20 +59,17 @@ function checkForUpdate() {
5159
});
5260
}
5361

54-
var isConfigValid = true;
55-
5662
var getConfiguration = (() => {
5763
var config;
5864
return function getConfiguration() {
59-
if (config && isConfigValid) {
65+
if (config) {
6066
return Promise.resolve(config);
6167
} else if (testConfig) {
6268
return Promise.resolve(testConfig);
6369
} else {
6470
return NativeCodePush.getConfiguration()
6571
.then((configuration) => {
6672
if (!config) config = configuration;
67-
isConfigValid = true;
6873
return config;
6974
});
7075
}
@@ -136,6 +141,7 @@ function setUpTestDependencies(providedTestSdk, providedTestConfig, testNativeBr
136141
function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) {
137142
var syncOptions = {
138143

144+
deploymentKey: null,
139145
ignoreFailedUpdates: true,
140146
installMode: CodePush.InstallMode.ON_NEXT_RESTART,
141147
rollbackTimeout: 0,
@@ -191,7 +197,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
191197

192198
return new Promise((resolve, reject) => {
193199
syncStatusChangeCallback(CodePush.SyncStatus.CHECKING_FOR_UPDATE);
194-
checkForUpdate()
200+
checkForUpdate(syncOptions.deploymentKey)
195201
.then((remotePackage) => {
196202
var doDownloadAndInstall = () => {
197203
syncStatusChangeCallback(CodePush.SyncStatus.DOWNLOADING_PACKAGE);

0 commit comments

Comments
 (0)