@@ -6,13 +6,21 @@ var packageMixins = require("./package-mixins")(NativeCodePush);
6
6
var requestFetchAdapter = require ( "./request-fetch-adapter.js" ) ;
7
7
var Sdk = require ( "code-push/script/acquisition-sdk" ) . AcquisitionManager ;
8
8
9
- function checkForUpdate ( ) {
9
+ function checkForUpdate ( deploymentKey ) {
10
10
var config ;
11
11
var sdk ;
12
12
13
13
return getConfiguration ( )
14
14
. then ( ( configResult ) => {
15
15
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
+
16
24
return getSdk ( ) ;
17
25
} )
18
26
. then ( ( sdkResult ) => {
@@ -51,20 +59,17 @@ function checkForUpdate() {
51
59
} ) ;
52
60
}
53
61
54
- var isConfigValid = true ;
55
-
56
62
var getConfiguration = ( ( ) => {
57
63
var config ;
58
64
return function getConfiguration ( ) {
59
- if ( config && isConfigValid ) {
65
+ if ( config ) {
60
66
return Promise . resolve ( config ) ;
61
67
} else if ( testConfig ) {
62
68
return Promise . resolve ( testConfig ) ;
63
69
} else {
64
70
return NativeCodePush . getConfiguration ( )
65
71
. then ( ( configuration ) => {
66
72
if ( ! config ) config = configuration ;
67
- isConfigValid = true ;
68
73
return config ;
69
74
} ) ;
70
75
}
@@ -136,6 +141,7 @@ function setUpTestDependencies(providedTestSdk, providedTestConfig, testNativeBr
136
141
function sync ( options = { } , syncStatusChangeCallback , downloadProgressCallback ) {
137
142
var syncOptions = {
138
143
144
+ deploymentKey : null ,
139
145
ignoreFailedUpdates : true ,
140
146
installMode : CodePush . InstallMode . ON_NEXT_RESTART ,
141
147
rollbackTimeout : 0 ,
@@ -191,7 +197,7 @@ function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback)
191
197
192
198
return new Promise ( ( resolve , reject ) => {
193
199
syncStatusChangeCallback ( CodePush . SyncStatus . CHECKING_FOR_UPDATE ) ;
194
- checkForUpdate ( )
200
+ checkForUpdate ( syncOptions . deploymentKey )
195
201
. then ( ( remotePackage ) => {
196
202
var doDownloadAndInstall = ( ) => {
197
203
syncStatusChangeCallback ( CodePush . SyncStatus . DOWNLOADING_PACKAGE ) ;
0 commit comments