@appzung/react-native-code-push 6.3.1 → 6.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CodePush.js +4 -0
- package/CodePush.podspec +1 -1
- package/README.md +32 -19
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +14 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +72 -0
- package/docs/multi-deployment-testing-android.md +1 -1
- package/docs/multi-deployment-testing-ios.md +1 -1
- package/docs/setup-android.md +7 -6
- package/docs/setup-ios.md +5 -5
- package/docs/setup-windows.md +1 -1
- package/ios/CodePush/CodePush.m +26 -11
- package/package.json +11 -11
package/CodePush.js
CHANGED
|
@@ -188,6 +188,10 @@ async function tryReportStatus(statusReport, resumeListener) {
|
|
|
188
188
|
if (statusReport.appVersion) {
|
|
189
189
|
log(`Reporting binary update (${statusReport.appVersion})`);
|
|
190
190
|
|
|
191
|
+
if (!config.deploymentKey) {
|
|
192
|
+
throw new Error("Deployment key is missed");
|
|
193
|
+
}
|
|
194
|
+
|
|
191
195
|
const sdk = getPromisifiedSdk(requestFetchAdapter, config);
|
|
192
196
|
await sdk.reportStatusDeploy(/* deployedPackage */ null, /* status */ null, previousLabelOrAppVersion, previousDeploymentKey);
|
|
193
197
|
} else {
|
package/CodePush.podspec
CHANGED
|
@@ -20,7 +20,7 @@ Pod::Spec.new do |s|
|
|
|
20
20
|
# Note: Even though there are copy/pasted versions of some of these dependencies in the repo,
|
|
21
21
|
# we explicitly let CocoaPods pull in the versions below so all dependencies are resolved and
|
|
22
22
|
# linked properly at a parent workspace level.
|
|
23
|
-
s.dependency 'React'
|
|
23
|
+
s.dependency 'React-Core'
|
|
24
24
|
s.dependency 'SSZipArchive', '~> 2.2.2'
|
|
25
25
|
s.dependency 'JWT', '~> 3.0.0-beta.12'
|
|
26
26
|
s.dependency 'Base64', '~> 1.1'
|
package/README.md
CHANGED
|
@@ -74,7 +74,9 @@ We try our best to maintain backwards compatibility of our plugin with previous
|
|
|
74
74
|
| v0.56-v0.58 | v5.4+ *(RN upgraded versions for Android tools)* |
|
|
75
75
|
| v0.59 | v5.6+ *(RN refactored js bundle loader code)* |
|
|
76
76
|
| v0.60-v0.61 | v6.0+ *(RN migrated to Autolinking)* |
|
|
77
|
-
| v0.62
|
|
77
|
+
| v0.62-v0.63 | v6.2+ *(RN removed LiveReload)* |
|
|
78
|
+
|
|
79
|
+
*NOTE: `react-native-code-push` versions lower than **[v5.7.0](https://github.com/microsoft/react-native-code-push/releases/tag/v5.7.0)** will stop working in the near future. You can find more information in our [documentation](https://github.com/microsoft/code-push/blob/master/migration-notice.md).*
|
|
78
80
|
|
|
79
81
|
We work hard to respond to new RN releases, but they do occasionally break us. We will update this chart with each RN release, so that users can check to see what our "official" support is.
|
|
80
82
|
|
|
@@ -244,7 +246,16 @@ If you would like to display an update confirmation dialog (an "active install")
|
|
|
244
246
|
|
|
245
247
|
### Store Guideline Compliance
|
|
246
248
|
|
|
247
|
-
|
|
249
|
+
Android Google Play and iOS App Store have corresponding guidelines that have rules you should be aware of before integrating the CodePush solution within your application.
|
|
250
|
+
|
|
251
|
+
#### Google play
|
|
252
|
+
|
|
253
|
+
Third paragraph of [Device and Network Abuse](https://support.google.com/googleplay/android-developer/answer/9888379?hl=en) topic describe that updating source code by any method other than Google Play's update mechanism is restricted. But this restriction is not apply to updating javascript bundles.
|
|
254
|
+
> This restriction does not apply to code that runs in a virtual machine and has limited access to Android APIs (such as JavaScript in a webview or browser).
|
|
255
|
+
|
|
256
|
+
That fully allow CodePush as it updates just JS bundles and can't update native code part.
|
|
257
|
+
|
|
258
|
+
#### App Store
|
|
248
259
|
|
|
249
260
|
Paragraph **3.3.2**, since back in 2015's [Apple Developer Program License Agreement](https://developer.apple.com/programs/ios/information/) fully allowed performing over-the-air updates of JavaScript and assets - and in its latest version (20170605) [downloadable here](https://developer.apple.com/terms/) this ruling is even broader:
|
|
250
261
|
|
|
@@ -260,33 +271,35 @@ This is not necessarily the case for `updateDialog`, since it won't force the us
|
|
|
260
271
|
|
|
261
272
|
## Releasing Updates
|
|
262
273
|
|
|
263
|
-
Once your app
|
|
274
|
+
Once your app is configured and distributed to your users, and you have made some JS or asset changes, it's time to release them. The recommended way to release them is using the `release-react` command in the App Center CLI, which will bundle your JavaScript files, asset files, and release the update to the CodePush server.
|
|
275
|
+
|
|
276
|
+
*NOTE: Before you can start releasing updates, please log into App Center by running the `appcenter login` command.*
|
|
264
277
|
|
|
265
|
-
In it's most basic form, this command only requires
|
|
278
|
+
In it's the most basic form, this command only requires one parameter: your owner name + "/" + app name.
|
|
266
279
|
|
|
267
280
|
```shell
|
|
268
|
-
|
|
281
|
+
appcenter codepush release-react -a <ownerName>/<appName>
|
|
269
282
|
|
|
270
|
-
|
|
271
|
-
|
|
283
|
+
appcenter codepush release-react -a <ownerName>/MyApp-iOS
|
|
284
|
+
appcenter codepush release-react -a <ownerName>/MyApp-Android
|
|
272
285
|
```
|
|
273
286
|
|
|
274
287
|
The `release-react` command enables such a simple workflow because it provides many sensible defaults (like generating a release bundle, assuming your app's entry file on iOS is either `index.ios.js` or `index.js`). However, all of these defaults can be customized to allow incremental flexibility as necessary, which makes it a good fit for most scenarios.
|
|
275
288
|
|
|
276
289
|
```shell
|
|
277
290
|
# Release a mandatory update with a changelog
|
|
278
|
-
|
|
291
|
+
appcenter codepush release-react -a <ownerName>/MyApp-iOS -m --description "Modified the header color"
|
|
279
292
|
|
|
280
293
|
# Release an update for an app that uses a non-standard entry file name, and also capture
|
|
281
294
|
# the sourcemap file generated by react-native bundle
|
|
282
|
-
|
|
295
|
+
appcenter codepush release-react -a <ownerName>/MyApp-iOS --entry-file MyApp.js --sourcemap-output ../maps/MyApp.map
|
|
283
296
|
|
|
284
297
|
# Release a dev Android build to just 1/4 of your end users
|
|
285
|
-
|
|
298
|
+
appcenter codepush release-react -a <ownerName>/MyApp-Android --rollout 25 --development true
|
|
286
299
|
|
|
287
300
|
# Release an update that targets users running any 1.1.* binary, as opposed to
|
|
288
301
|
# limiting the update to exact version name in the build.gradle file
|
|
289
|
-
|
|
302
|
+
appcenter codepush release-react -a <ownerName>/MyApp-Android --target-binary-version "~1.1.0"
|
|
290
303
|
|
|
291
304
|
```
|
|
292
305
|
|
|
@@ -302,19 +315,19 @@ If you run into any issues, or have any questions/comments/feedback, you can pin
|
|
|
302
315
|
|
|
303
316
|
In our [getting started](#getting-started) docs, we illustrated how to configure the CodePush plugin using a specific deployment key. However, in order to effectively test your releases, it is critical that you leverage the `Staging` and `Production` deployments that are auto-generated when you first created your CodePush app (or any custom deployments you may have created). This way, you never release an update to your end users that you haven't been able to validate yourself.
|
|
304
317
|
|
|
305
|
-
*NOTE: Our client-side rollback feature can help unblock users after installing a release that resulted in a crash, and server-side rollbacks (i.e. `
|
|
318
|
+
*NOTE: Our client-side rollback feature can help unblock users after installing a release that resulted in a crash, and server-side rollbacks (i.e. `appcenter codepush rollback`) allow you to prevent additional users from installing a bad release once it's been identified. However, it's obviously better if you can prevent an erroneous update from being broadly released in the first place.*
|
|
306
319
|
|
|
307
320
|
Taking advantage of the `Staging` and `Production` deployments allows you to achieve a workflow like the following (feel free to customize!):
|
|
308
321
|
|
|
309
|
-
1. Release a CodePush update to your `Staging` deployment using the `
|
|
322
|
+
1. Release a CodePush update to your `Staging` deployment using the `appcenter codepush release-react` command (or `appcenter codepush release` if you need more control)
|
|
310
323
|
|
|
311
324
|
2. Run your staging/beta build of your app, sync the update from the server, and verify it works as expected
|
|
312
325
|
|
|
313
|
-
3. Promote the tested release from `Staging` to `Production` using the `
|
|
326
|
+
3. Promote the tested release from `Staging` to `Production` using the `appcenter codepush promote` command
|
|
314
327
|
|
|
315
328
|
4. Run your production/release build of your app, sync the update from the server and verify it works as expected
|
|
316
329
|
|
|
317
|
-
*NOTE: If you want to
|
|
330
|
+
*NOTE: If you want to take a more cautious approach, you can even choose to perform a "staged rollout" as part of #3, which allows you to mitigate additional potential risk with the update (like did your testing in #2 touch all possible devices/conditions?) by only making the production update available to a percentage of your users (for example `appcenter codepush promote -a <ownerName>/<appName> -s Staging -d Production -r 20`). Then, after waiting for a reasonable amount of time to see if any crash reports or customer feedback comes in, you can expand it to your entire audience by running `appcenter codepush patch -a <ownerName>/<appName> Production -r 100`.*
|
|
318
331
|
|
|
319
332
|
You'll notice that the above steps refer to a "staging build" and "production build" of your app. If your build process already generates distinct binaries per "environment", then you don't need to read any further, since swapping out CodePush deployment keys is just like handling environment-specific config for any other service your app uses (like Facebook). However, if you're looking for examples (**including demo projects**) on how to setup your build process to accommodate this, then refer to the following sections, depending on the platform(s) your app is targeting:
|
|
320
333
|
|
|
@@ -346,10 +359,10 @@ Since we recommend using the `Staging` deployment for pre-release testing of you
|
|
|
346
359
|
|
|
347
360
|
```javascript
|
|
348
361
|
// #1) Create your new deployment to hold releases of a specific app variant
|
|
349
|
-
|
|
362
|
+
appcenter codepush deployment add -a <ownerName>/<appName> test-variant-one
|
|
350
363
|
|
|
351
364
|
// #2) Target any new releases at that custom deployment
|
|
352
|
-
|
|
365
|
+
appcenter codepush release-react -a <ownerName>/<appName> -d test-variant-one
|
|
353
366
|
```
|
|
354
367
|
|
|
355
368
|
*NOTE: The total user count that is reported in your deployment's "Install Metrics" will take into account users that have "switched" from one deployment to another. For example, if your `Production` deployment currently reports having 1 total user, but you dynamically switch that user to `Staging`, then the `Production` deployment would report 0 total users, while `Staging` would report 1 (the user that just switched). This behavior allows you to accurately track your release adoption, even in the event of using a runtime-based deployment redirection solution.*
|
|
@@ -382,7 +395,7 @@ Additionally, if you're looking to get started with React Native + CodePush, and
|
|
|
382
395
|
|
|
383
396
|
The `sync` method includes a lot of diagnostic logging out-of-the-box, so if you're encountering an issue when using it, the best thing to try first is examining the output logs of your app. This will tell you whether the app is configured correctly (like can the plugin find your deployment key?), if the app is able to reach the server, if an available update is being discovered, if the update is being successfully downloaded/installed, etc. We want to continue improving the logging to be as intuitive/comprehensive as possible, so please [let us know](mailto:codepushfeed@microsoft.com) if you find it to be confusing or missing anything.
|
|
384
397
|
|
|
385
|
-
The simplest way to view these logs is to
|
|
398
|
+
The simplest way to view these logs is to add the flag `--debug` for each command. This will output a log stream that is filtered to just CodePush messages. This makes it easy to identify issues, without needing to use a platform-specific tool, or wade through a potentially high volume of logs.
|
|
386
399
|
|
|
387
400
|
<img width="540" alt="screen shot 2016-06-21 at 10 15 42 am" src="https://cloud.githubusercontent.com/assets/116461/16246973/838e2e98-37bc-11e6-9649-685f39e325a0.png">
|
|
388
401
|
|
|
@@ -404,7 +417,7 @@ Now you'll be able to see CodePush logs in either debug or release mode, on both
|
|
|
404
417
|
|-----------------|-------------------|
|
|
405
418
|
| Compilation Error | Double-check that your version of React Native is [compatible](#supported-react-native-platforms) with the CodePush version you are using. |
|
|
406
419
|
| Network timeout / hang when calling `sync` or `checkForUpdate` in the iOS Simulator | Try resetting the simulator by selecting the `Simulator -> Reset Content and Settings..` menu item, and then re-running your app. |
|
|
407
|
-
| Server responds with a `404` when calling `sync` or `checkForUpdate` | Double-check that the deployment key you added to your `Info.plist` (iOS), `build.gradle` (Android) or that you're passing to `sync`/`checkForUpdate`, is in fact correct. You can run `
|
|
420
|
+
| Server responds with a `404` when calling `sync` or `checkForUpdate` | Double-check that the deployment key you added to your `Info.plist` (iOS), `build.gradle` (Android) or that you're passing to `sync`/`checkForUpdate`, is in fact correct. You can run `appcenter codepush deployment list <ownerName>/<appName> --displayKeys` to view the correct keys for your app deployments. |
|
|
408
421
|
| Update not being discovered | Double-check that the version of your running app (like `1.0.0`) matches the version you specified when releasing the update to CodePush. Additionally, make sure that you are releasing to the same deployment that your app is configured to sync with. |
|
|
409
422
|
| Update not being displayed after restart | If you're not calling `sync` on app start (like within `componentDidMount` of your root component), then you need to explicitly call `notifyApplicationReady` on app start, otherwise, the plugin will think your update failed and roll it back. |
|
|
410
423
|
| I've released an update for iOS but my Android app also shows an update and it breaks it | Be sure you have different deployment keys for each platform in order to receive updates correctly |
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.microsoft.codepush.react;
|
|
2
2
|
|
|
3
|
+
import android.os.Build;
|
|
4
|
+
|
|
3
5
|
import org.json.JSONObject;
|
|
4
6
|
|
|
5
7
|
import java.io.BufferedInputStream;
|
|
@@ -12,6 +14,8 @@ import java.net.MalformedURLException;
|
|
|
12
14
|
import java.net.URL;
|
|
13
15
|
import java.nio.ByteBuffer;
|
|
14
16
|
|
|
17
|
+
import javax.net.ssl.HttpsURLConnection;
|
|
18
|
+
|
|
15
19
|
public class CodePushUpdateManager {
|
|
16
20
|
|
|
17
21
|
private String mDocumentsDirectory;
|
|
@@ -163,6 +167,16 @@ public class CodePushUpdateManager {
|
|
|
163
167
|
try {
|
|
164
168
|
URL downloadUrl = new URL(downloadUrlString);
|
|
165
169
|
connection = (HttpURLConnection) (downloadUrl.openConnection());
|
|
170
|
+
|
|
171
|
+
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP &&
|
|
172
|
+
downloadUrl.toString().startsWith("https")) {
|
|
173
|
+
try {
|
|
174
|
+
((HttpsURLConnection)connection).setSSLSocketFactory(new TLSSocketFactory());
|
|
175
|
+
} catch (Exception e) {
|
|
176
|
+
throw new CodePushUnknownException("Error set SSLSocketFactory. ", e);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
166
180
|
connection.setRequestProperty("Accept-Encoding", "identity");
|
|
167
181
|
bin = new BufferedInputStream(connection.getInputStream());
|
|
168
182
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
package com.microsoft.codepush.react;
|
|
2
|
+
|
|
3
|
+
import java.io.IOException;
|
|
4
|
+
import java.net.InetAddress;
|
|
5
|
+
import java.net.Socket;
|
|
6
|
+
import java.net.UnknownHostException;
|
|
7
|
+
import java.security.KeyManagementException;
|
|
8
|
+
import java.security.NoSuchAlgorithmException;
|
|
9
|
+
|
|
10
|
+
import javax.net.ssl.SSLContext;
|
|
11
|
+
import javax.net.ssl.SSLSocket;
|
|
12
|
+
import javax.net.ssl.SSLSocketFactory;
|
|
13
|
+
|
|
14
|
+
public class TLSSocketFactory extends SSLSocketFactory {
|
|
15
|
+
|
|
16
|
+
private SSLSocketFactory delegate;
|
|
17
|
+
|
|
18
|
+
public TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException {
|
|
19
|
+
SSLContext context = SSLContext.getInstance("TLS");
|
|
20
|
+
context.init(null, null, null);
|
|
21
|
+
delegate = context.getSocketFactory();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
public String[] getDefaultCipherSuites() {
|
|
26
|
+
return delegate.getDefaultCipherSuites();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public String[] getSupportedCipherSuites() {
|
|
31
|
+
return delegate.getSupportedCipherSuites();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
public Socket createSocket() throws IOException {
|
|
36
|
+
return enableTLSOnSocket(delegate.createSocket());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException {
|
|
41
|
+
return enableTLSOnSocket(delegate.createSocket(s, host, port, autoClose));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
|
|
46
|
+
return enableTLSOnSocket(delegate.createSocket(host, port));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Override
|
|
50
|
+
public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
|
|
51
|
+
throws IOException, UnknownHostException {
|
|
52
|
+
return enableTLSOnSocket(delegate.createSocket(host, port, localHost, localPort));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Override
|
|
56
|
+
public Socket createSocket(InetAddress host, int port) throws IOException {
|
|
57
|
+
return enableTLSOnSocket(delegate.createSocket(host, port));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Override
|
|
61
|
+
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
|
|
62
|
+
throws IOException {
|
|
63
|
+
return enableTLSOnSocket(delegate.createSocket(address, port, localAddress, localPort));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private Socket enableTLSOnSocket(Socket socket) {
|
|
67
|
+
if (socket != null && (socket instanceof SSLSocket)) {
|
|
68
|
+
((SSLSocket) socket).setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1.2" });
|
|
69
|
+
}
|
|
70
|
+
return socket;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
The [Android Gradle plugin](https://google.github.io/android-gradle-dsl/current/index.html) allows you to define custom config settings for each "build type" (like debug, release). This mechanism allows you to easily configure your debug builds to use your CodePush staging deployment key and your release builds to use your CodePush production deployment key.
|
|
8
8
|
|
|
9
|
-
*NOTE: As a reminder, you can retrieve these keys by running `
|
|
9
|
+
*NOTE: As a reminder, you can retrieve these keys by running `appcenter codepush deployment list -a <ownerName>/<appName> -k` from your terminal.*
|
|
10
10
|
|
|
11
11
|
To set this up, perform the following steps:
|
|
12
12
|
|
|
@@ -44,7 +44,7 @@ To set this up, perform the following steps:
|
|
|
44
44
|
|
|
45
45
|

|
|
46
46
|
|
|
47
|
-
*NOTE: As a reminder, you can retrieve these keys by running `
|
|
47
|
+
*NOTE: As a reminder, you can retrieve these keys by running `appcenter codepush deployment list -a <ownerName>/<appName> -k` from your terminal.*
|
|
48
48
|
|
|
49
49
|
9. Open your project's `Info.plist` file and change the value of your `CodePushDeploymentKey` entry to `$(CODEPUSH_KEY)`
|
|
50
50
|
|
package/docs/setup-android.md
CHANGED
|
@@ -19,9 +19,10 @@ In order to integrate CodePush into your Android project, please perform the fol
|
|
|
19
19
|
|
|
20
20
|
### Plugin Installation and Configuration for React Native 0.60 version and above (Android)
|
|
21
21
|
|
|
22
|
-
1. In your `android/settings.gradle` file, make the following additions:
|
|
22
|
+
1. In your `android/settings.gradle` file, make the following additions at the end of the file:
|
|
23
23
|
|
|
24
24
|
```gradle
|
|
25
|
+
...
|
|
25
26
|
include ':app', ':react-native-code-push'
|
|
26
27
|
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
|
|
27
28
|
```
|
|
@@ -59,8 +60,8 @@ In order to integrate CodePush into your Android project, please perform the fol
|
|
|
59
60
|
```
|
|
60
61
|
|
|
61
62
|
4. Add the Deployment key to `strings.xml`:
|
|
62
|
-
|
|
63
|
-
To let the CodePush runtime know which deployment it should query for updates, open your app's `strings.xml` file and add a new string named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `
|
|
63
|
+
|
|
64
|
+
To let the CodePush runtime know which deployment it should query for updates, open your app's `strings.xml` file and add a new string named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `appcenter codepush deployment list -a <ownerName>/<appName> -k` in the CodePush CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (like Staging) will not work. The "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app.
|
|
64
65
|
|
|
65
66
|

|
|
66
67
|
|
|
@@ -101,7 +102,7 @@ In order to accommodate as many developer preferences as possible, the CodePush
|
|
|
101
102
|
|
|
102
103
|
*Note: If you don't already have RNPM installed, you can do so by simply running `npm i -g rnpm` and then executing the above command.*
|
|
103
104
|
|
|
104
|
-
2. If you're using RNPM >=1.6.0, you will be prompted for the deployment key you'd like to use. If you don't already have it, you can retrieve this value by running `
|
|
105
|
+
2. If you're using RNPM >=1.6.0, you will be prompted for the deployment key you'd like to use. If you don't already have it, you can retrieve this value by running `appcenter codepush deployment list -a <ownerName>/<appName> -k`, or you can choose to ignore it (by simply hitting `<ENTER>`) and add it in later. To get started, we would recommend just using your `Staging` deployment key, so that you can test out the CodePush end-to-end.
|
|
105
106
|
|
|
106
107
|
And that's it for installation using RNPM! Continue below to the [Plugin Configuration](#plugin-configuration-for-react-native-lower-than-060-android) section to complete the setup.
|
|
107
108
|
|
|
@@ -168,7 +169,7 @@ public class MainApplication extends Application implements ReactApplication {
|
|
|
168
169
|
protected List<ReactPackage> getPackages() {
|
|
169
170
|
// 3. Instantiate an instance of the CodePush runtime and add it to the list of
|
|
170
171
|
// existing packages, specifying the right deployment key. If you don't already
|
|
171
|
-
// have it, you can run "
|
|
172
|
+
// have it, you can run "appcenter codepush deployment list -a <ownerName>/<appName> -k" to retrieve your key.
|
|
172
173
|
return Arrays.<ReactPackage>asList(
|
|
173
174
|
new MainReactPackage(),
|
|
174
175
|
new CodePush("deployment-key-here", MainApplication.this, BuildConfig.DEBUG)
|
|
@@ -245,7 +246,7 @@ public class MainActivity extends ReactActivity {
|
|
|
245
246
|
protected List<ReactPackage> getPackages() {
|
|
246
247
|
// 3. Instantiate an instance of the CodePush runtime and add it to the list of
|
|
247
248
|
// existing packages, specifying the right deployment key. If you don't already
|
|
248
|
-
// have it, you can run "
|
|
249
|
+
// have it, you can run "appcenter codepush deployment list -a <ownerName>/<appName> -k" to retrieve your key.
|
|
249
250
|
return Arrays.<ReactPackage>asList(
|
|
250
251
|
new MainReactPackage(),
|
|
251
252
|
new CodePush("deployment-key-here", this, BuildConfig.DEBUG)
|
package/docs/setup-ios.md
CHANGED
|
@@ -43,15 +43,15 @@ Once you've acquired the CodePush plugin, you need to integrate it into the Xcod
|
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
5. Add the Deployment key to `Info.plist`:
|
|
46
|
-
|
|
47
|
-
To let the CodePush runtime know which deployment it should query for updates against, open your app's `Info.plist` file and add a new entry named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `
|
|
46
|
+
|
|
47
|
+
To let the CodePush runtime know which deployment it should query for updates against, open your app's `Info.plist` file and add a new entry named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `appcenter codepush deployment list -a <ownerName>/<appName> -k` in the AppCenter CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (like Staging) will not work. That "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app.
|
|
48
48
|
|
|
49
49
|

|
|
50
50
|
|
|
51
51
|
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your CodePush app, refer to the [multi-deployment testing](../README.md#multi-deployment-testing) docs below before actually moving your app's usage of CodePush into production.
|
|
52
52
|
|
|
53
53
|
*Note: If you need to dynamically use a different deployment, you can also override your deployment key in JS code using [Code-Push options](./api-js.md#CodePushOptions)*
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
### Plugin Installation for React Native lower than 0.60 (iOS)
|
|
56
56
|
|
|
57
57
|
In order to accommodate as many developer preferences as possible, the CodePush plugin supports iOS installation via three mechanisms:
|
|
@@ -76,7 +76,7 @@ In order to accommodate as many developer preferences as possible, the CodePush
|
|
|
76
76
|
|
|
77
77
|
*Note: If you don't already have RNPM installed, you can do so by simply running `npm i -g rnpm` and then executing the above command. If you already have RNPM installed, make sure you have v1.9.0+ in order to benefit from this one step install.*
|
|
78
78
|
|
|
79
|
-
2. You will be prompted for the deployment key you'd like to use. If you don't already have it, you can retrieve this value by running `
|
|
79
|
+
2. You will be prompted for the deployment key you'd like to use. If you don't already have it, you can retrieve this value by running `appcenter codepush deployment list -a <ownerName>/<appName> -k`, or you can choose to ignore it (by simply hitting `<ENTER>`) and add it in later. To get started, we would recommend just using your `Staging` deployment key, so that you can test out the CodePush end-to-end.
|
|
80
80
|
|
|
81
81
|
And that's it! Isn't RNPM awesome? :)
|
|
82
82
|
|
|
@@ -218,7 +218,7 @@ NSURL *jsCodeLocation;
|
|
|
218
218
|
#endif
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
-
To let the CodePush runtime know which deployment it should query for updates against, open your app's `Info.plist` file and add a new entry named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `
|
|
221
|
+
To let the CodePush runtime know which deployment it should query for updates against, open your app's `Info.plist` file and add a new entry named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `appcenter codepush deployment list -a <ownerName>/<appName> -k` in the AppCenter CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (like Staging) will not work. That "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app.
|
|
222
222
|
|
|
223
223
|

|
|
224
224
|
|
package/docs/setup-windows.md
CHANGED
|
@@ -37,7 +37,7 @@ class MainReactNativeHost : ReactNativeHost
|
|
|
37
37
|
// 3. Update the JavaScriptBundleFile property to initalize the CodePush runtime,
|
|
38
38
|
// specifying the right deployment key, then use it to return the bundle URL from
|
|
39
39
|
// CodePush instead of statically from the binary. If you don't already have your
|
|
40
|
-
// deployment key, you can run "
|
|
40
|
+
// deployment key, you can run "appcenter codepush deployment list -a <ownerName>/<appName> -k" to retrieve it.
|
|
41
41
|
protected override string JavaScriptBundleFile
|
|
42
42
|
{
|
|
43
43
|
get
|
package/ios/CodePush/CodePush.m
CHANGED
|
@@ -643,28 +643,38 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
643
643
|
return @[DownloadProgressEvent];
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
// These two handlers will only be registered when there is
|
|
649
|
-
// a resume-based update still pending installation.
|
|
650
|
-
- (void)applicationWillEnterForeground
|
|
646
|
+
// Determine how long the app was in the background
|
|
647
|
+
- (int)getDurationInBackground
|
|
651
648
|
{
|
|
652
|
-
|
|
653
|
-
// that it meets the minimum duration amount of time.
|
|
654
|
-
int durationInBackground = 0;
|
|
649
|
+
int duration = 0;
|
|
655
650
|
if (_lastResignedDate) {
|
|
656
|
-
|
|
651
|
+
duration = [[NSDate date] timeIntervalSinceDate:_lastResignedDate];
|
|
657
652
|
}
|
|
658
653
|
|
|
654
|
+
return duration;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
#pragma mark - Application lifecycle event handlers
|
|
658
|
+
|
|
659
|
+
// These three handlers will only be registered when there is
|
|
660
|
+
// a resume-based update still pending installation.
|
|
661
|
+
- (void)applicationDidBecomeActive
|
|
662
|
+
{
|
|
659
663
|
if (_installMode == CodePushInstallModeOnNextSuspend) {
|
|
664
|
+
int durationInBackground = [self getDurationInBackground];
|
|
660
665
|
// We shouldn't use loadBundle in this case, because _appSuspendTimer will call loadBundleOnTick.
|
|
661
666
|
// We should cancel timer for _appSuspendTimer because otherwise, we would call loadBundle two times.
|
|
662
667
|
if (durationInBackground < _minimumBackgroundDuration) {
|
|
663
668
|
[_appSuspendTimer invalidate];
|
|
664
669
|
_appSuspendTimer = nil;
|
|
665
670
|
}
|
|
666
|
-
}
|
|
667
|
-
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
- (void)applicationWillEnterForeground
|
|
675
|
+
{
|
|
676
|
+
if (_installMode == CodePushInstallModeOnNextResume) {
|
|
677
|
+
int durationInBackground = [self getDurationInBackground];
|
|
668
678
|
if (durationInBackground >= _minimumBackgroundDuration) {
|
|
669
679
|
[self restartAppInternal:NO];
|
|
670
680
|
}
|
|
@@ -899,6 +909,11 @@ RCT_EXPORT_METHOD(installUpdate:(NSDictionary*)updatePackage
|
|
|
899
909
|
// Ensure we do not add the listener twice.
|
|
900
910
|
// Register for app resume notifications so that we
|
|
901
911
|
// can check for pending updates which support "restart on resume"
|
|
912
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
913
|
+
selector:@selector(applicationDidBecomeActive)
|
|
914
|
+
name:UIApplicationDidBecomeActiveNotification
|
|
915
|
+
object:RCTSharedApplication()];
|
|
916
|
+
|
|
902
917
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
903
918
|
selector:@selector(applicationWillEnterForeground)
|
|
904
919
|
name:UIApplicationWillEnterForegroundNotification
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appzung/react-native-code-push",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.2",
|
|
4
4
|
"description": "React Native plugin for the CodePush service",
|
|
5
5
|
"main": "CodePush.js",
|
|
6
6
|
"typings": "typings/react-native-code-push.d.ts",
|
|
@@ -25,33 +25,33 @@
|
|
|
25
25
|
"tslint": "tslint -c tslint.json test/**/*.ts"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"code-push": "^
|
|
28
|
+
"code-push": "^4.0.2",
|
|
29
29
|
"glob": "^7.1.6",
|
|
30
30
|
"hoist-non-react-statics": "^3.3.2",
|
|
31
|
-
"inquirer": "^7.
|
|
31
|
+
"inquirer": "^7.3.3",
|
|
32
32
|
"plist": "3.0.1",
|
|
33
33
|
"semver": "^7.3.2",
|
|
34
34
|
"xcode": "3.0.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/assert": "^1.
|
|
38
|
-
"@types/mkdirp": "^1.0.
|
|
39
|
-
"@types/mocha": "^
|
|
40
|
-
"@types/node": "^14.0.
|
|
41
|
-
"@types/q": "^1.5.
|
|
37
|
+
"@types/assert": "^1.5.2",
|
|
38
|
+
"@types/mkdirp": "^1.0.1",
|
|
39
|
+
"@types/mocha": "^8.0.3",
|
|
40
|
+
"@types/node": "^14.0.27",
|
|
41
|
+
"@types/q": "^1.5.4",
|
|
42
42
|
"archiver": "latest",
|
|
43
43
|
"body-parser": "latest",
|
|
44
44
|
"code-push-plugin-testing-framework": "file:./code-push-plugin-testing-framework",
|
|
45
45
|
"del": "latest",
|
|
46
46
|
"express": "latest",
|
|
47
47
|
"mkdirp": "latest",
|
|
48
|
-
"mocha": "^8.
|
|
48
|
+
"mocha": "^8.1.3",
|
|
49
49
|
"q": "^1.5.1",
|
|
50
50
|
"run-sequence": "latest",
|
|
51
51
|
"shx": "^0.3.2",
|
|
52
52
|
"slash": "^3.0.0",
|
|
53
|
-
"tslint": "^6.1.
|
|
54
|
-
"typescript": "^
|
|
53
|
+
"tslint": "^6.1.3",
|
|
54
|
+
"typescript": "^4.0.3"
|
|
55
55
|
},
|
|
56
56
|
"rnpm": {
|
|
57
57
|
"android": {
|