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

Commit a636482

Browse files
committed
update to master again
2 parents b125060 + f99a6ce commit a636482

File tree

4 files changed

+177
-80
lines changed

4 files changed

+177
-80
lines changed

CodePush.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#import "RCTBridgeModule.h"
22

3-
@interface CodePush : NSObject<RCTBridgeModule>
4-
3+
@interface CodePush : NSObject <RCTBridgeModule>
4+
5+
/*
6+
* This method is used to retrieve the URL for the most recent
7+
* version of the JavaScript bundle. This could be either the
8+
* bundle that was packaged with the app binary, or the bundle
9+
* that was downloaded as part of a CodePush update. The value returned
10+
* should be used to "bootstrap" the React Native bridge.
11+
*
12+
* This method assumes that your JS bundle is named "main.jsbundle"
13+
* and therefore, if it isn't, you should use either the bundleURLForResource:
14+
* or bundleURLForResource:withExtension: methods to override that behavior.
15+
*/
516
+ (NSURL *)bundleURL;
617

718
+ (NSURL *)bundleURLForResource:(NSString *)resourceName;
@@ -25,7 +36,7 @@
2536

2637
@end
2738

28-
@interface CodePushDownloadHandler : NSObject<NSURLConnectionDelegate>
39+
@interface CodePushDownloadHandler : NSObject <NSURLConnectionDelegate>
2940

3041
@property (strong) NSOutputStream *outputFileStream;
3142
@property long expectedContentLength;

CodePush.js

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,20 @@ var Sdk = require("code-push/script/acquisition-sdk").AcquisitionManager;
55
var { NativeCodePush, PackageMixins, Alert } = require("./CodePushNativePlatformAdapter");
66

77
function checkForUpdate(deploymentKey = null) {
8-
var config;
9-
var sdk;
8+
var config, sdk;
109

1110
return getConfiguration()
12-
.then((configResult) => {
13-
config = configResult;
14-
11+
.then((configResult) => {
1512
// If a deployment key was explicitly provided,
1613
// then let's override the one we retrieved
1714
// from the native-side of the app.
1815
if (deploymentKey) {
19-
config.deploymentKey = deploymentKey;
16+
config = Object.assign({}, configResult, { deploymentKey });
17+
} else {
18+
config = configResult;
2019
}
2120

22-
return getSdk();
23-
})
24-
.then((sdkResult) => {
25-
sdk = sdkResult;
21+
sdk = getSDK(config);
2622
// Allow dynamic overwrite of function. This is only to be used for tests.
2723
return module.exports.getCurrentPackage();
2824
})
@@ -74,23 +70,6 @@ var getConfiguration = (() => {
7470
}
7571
})();
7672

77-
var getSdk = (() => {
78-
var sdk;
79-
return function getSdk() {
80-
if (sdk) {
81-
return Promise.resolve(sdk);
82-
} else if (testSdk) {
83-
return Promise.resolve(testSdk);
84-
} else {
85-
return getConfiguration()
86-
.then((configuration) => {
87-
sdk = new Sdk(requestFetchAdapter, configuration);
88-
return sdk;
89-
});
90-
}
91-
}
92-
})();
93-
9473
function getCurrentPackage() {
9574
return new Promise((resolve, reject) => {
9675
var localPackage;
@@ -112,6 +91,14 @@ function getCurrentPackage() {
11291
});
11392
}
11493

94+
function getSDK(config) {
95+
if (testSdk) {
96+
return testSdk;
97+
} else {
98+
return new Sdk(requestFetchAdapter, config);
99+
}
100+
}
101+
115102
/* Logs messages to console with the [CodePush] prefix */
116103
function log(message) {
117104
console.log(`[CodePush] ${message}`)

0 commit comments

Comments
 (0)