@srcpush/react-native-code-push 1.0.3-feat-new-architecture.1 → 1.0.3-main.1
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 +2 -2
- package/README.md +15 -15
- package/SECURITY.md +5 -21
- package/android/app/build.gradle +0 -10
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +14 -27
- package/docs/api-android.md +10 -10
- package/docs/api-ios.md +5 -5
- package/docs/api-js.md +17 -17
- package/docs/multi-deployment-testing-android.md +2 -2
- package/docs/multi-deployment-testing-ios.md +1 -1
- package/docs/setup-android.md +7 -7
- package/docs/setup-ios.md +9 -9
- package/docs/setup-windows.md +6 -6
- package/package.json +1 -9
- package/android/app/src/newarch/java/com/microsoft/codepush/react/CodePushNativeModuleSpec.java +0 -9
- package/android/app/src/oldarch/java/com/microsoft/codepush/react/CodePushNativeModuleSpec.java +0 -34
- package/src/NativeCodePush.ts +0 -39
package/CodePush.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk";
|
|
2
2
|
import { Alert } from "./AlertAdapter";
|
|
3
3
|
import requestFetchAdapter from "./request-fetch-adapter";
|
|
4
|
-
import { AppState, Platform
|
|
4
|
+
import { AppState, Platform } from "react-native";
|
|
5
5
|
import log from "./logging";
|
|
6
6
|
import hoistStatics from 'hoist-non-react-statics';
|
|
7
7
|
|
|
8
|
-
let NativeCodePush =
|
|
8
|
+
let NativeCodePush = require("react-native").NativeModules.CodePush;
|
|
9
9
|
const PackageMixins = require("./package-mixins")(NativeCodePush);
|
|
10
10
|
|
|
11
11
|
async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchCallback = null) {
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#### [Sign up With Source Push](https://console.srcpush.com/register) to use
|
|
1
|
+
#### [Sign up With Source Push](https://console.srcpush.com/register) to use Source Push SDK
|
|
2
2
|
|
|
3
3
|
# React Native SDK for Source Push (CodePush compatible service)
|
|
4
4
|
|
|
5
|
-
This plugin provides client-side integration for the [
|
|
5
|
+
This plugin provides client-side integration for the [Source Push service](https://srcpush.com/), allowing you to easily add a dynamic update experience to your React Native app(s).
|
|
6
6
|
|
|
7
7
|
<!-- React Native Catalog -->
|
|
8
8
|
|
|
@@ -34,20 +34,20 @@ This plugin provides client-side integration for the [CodePush service](https://
|
|
|
34
34
|
|
|
35
35
|
A React Native app is composed of JavaScript files and any accompanying [images](https://reactnative.dev/docs/image), which are bundled together by the [metro bundler](https://github.com/facebook/metro) and distributed as part of a platform-specific binary (i.e. an `.ipa` or `.apk` file). Once the app is released, updating either the JavaScript code (e.g. making bug fixes, adding new features) or image assets, requires you to recompile and redistribute the entire binary, which of course, includes any review time associated with the store(s) you are publishing to.
|
|
36
36
|
|
|
37
|
-
The
|
|
37
|
+
The Source Push plugin helps get product improvements in front of your end users instantly, by keeping your JavaScript and images synchronized with updates you release to the Source Push server. This way, your app gets the benefits of an offline mobile experience, as well as the "web-like" agility of side-loading updates as soon as they are available. It's a win-win!
|
|
38
38
|
|
|
39
|
-
In order to ensure that your end users always have a functioning version of your app, the
|
|
39
|
+
In order to ensure that your end users always have a functioning version of your app, the Source Push plugin maintains a copy of the previous update, so that in the event that you accidentally push an update which includes a crash, it can automatically roll back. This way, you can rest assured that your newfound release agility won't result in users becoming blocked before you have a chance to roll back on the server. It's a win-win-win!
|
|
40
40
|
|
|
41
|
-
*Note: Any product changes which touch native code (e.g. modifying your `AppDelegate.m`/`MainActivity.java` file, adding a new plugin) cannot be distributed via
|
|
41
|
+
*Note: Any product changes which touch native code (e.g. modifying your `AppDelegate.m`/`MainActivity.java` file, adding a new plugin) cannot be distributed via Source Push, and therefore, must be updated via the appropriate store(s).*
|
|
42
42
|
|
|
43
43
|
## Supported React Native platforms
|
|
44
44
|
|
|
45
45
|
* iOS (7+)
|
|
46
46
|
* Android (4.1+) on TLS 1.2 compatible devices
|
|
47
47
|
|
|
48
|
-
We try our best to maintain backwards compatibility of our plugin with previous versions of React Native, but due to the nature of the platform, and the existence of breaking changes between releases, it is possible that you need to use a specific version of the
|
|
48
|
+
We try our best to maintain backwards compatibility of our plugin with previous versions of React Native, but due to the nature of the platform, and the existence of breaking changes between releases, it is possible that you need to use a specific version of the Source Push plugin in order to support the exact version of React Native you are using. The following table outlines which Source Push plugin versions officially support the respective React Native versions:
|
|
49
49
|
|
|
50
|
-
| React Native version(s) | Supporting
|
|
50
|
+
| React Native version(s) | Supporting Source Push version(s) |
|
|
51
51
|
|-------------------------|---------------------------------------------------------------------------------------------|
|
|
52
52
|
| <v0.76 | Use [microsoft/code-push-react-native](https://github.com/microsoft/react-native-code-push) |
|
|
53
53
|
| v0.76, v0.77, 0.78 | v1.0+ *(Support both New and Old Architectures)* |
|
|
@@ -56,7 +56,7 @@ We work hard to respond to new RN releases, but they do occasionally break us. W
|
|
|
56
56
|
|
|
57
57
|
### Supported Components
|
|
58
58
|
|
|
59
|
-
When using the React Native assets system (i.e. using the `require("./foo.png")` syntax), the following list represents the set of core components (and props) that support having their referenced images and videos updated via
|
|
59
|
+
When using the React Native assets system (i.e. using the `require("./foo.png")` syntax), the following list represents the set of core components (and props) that support having their referenced images and videos updated via Source Push:
|
|
60
60
|
|
|
61
61
|
| Component | Prop(s) |
|
|
62
62
|
|-------------------------------------------------|------------------------------------------|
|
|
@@ -67,16 +67,16 @@ When using the React Native assets system (i.e. using the `require("./foo.png")`
|
|
|
67
67
|
| `ToolbarAndroid` <br />*(React Native 0.21.0+)* | `actions[].icon`, `logo`, `overflowIcon` |
|
|
68
68
|
| `Video` | `source` |
|
|
69
69
|
|
|
70
|
-
The following list represents the set of components (and props) that don't currently support their assets being updated via
|
|
70
|
+
The following list represents the set of components (and props) that don't currently support their assets being updated via Source Push, due to their dependency on static images and videos (i.e. using the `{ uri: "foo" }` syntax):
|
|
71
71
|
|
|
72
72
|
| Component | Prop(s) |
|
|
73
73
|
|-------------|----------------------------------------------------------------------|
|
|
74
74
|
| `SliderIOS` | `maximumTrackImage`, `minimumTrackImage`, `thumbImage`, `trackImage` |
|
|
75
75
|
| `Video` | `source` |
|
|
76
76
|
|
|
77
|
-
As new core components are released, which support referencing assets, we'll update this list to ensure users know what exactly they can expect to update using
|
|
77
|
+
As new core components are released, which support referencing assets, we'll update this list to ensure users know what exactly they can expect to update using Source Push.
|
|
78
78
|
|
|
79
|
-
*Note:
|
|
79
|
+
*Note: Source Push only works with Video components when using `require` in the source prop. For example:*
|
|
80
80
|
|
|
81
81
|
```javascript
|
|
82
82
|
<Video source={require("./foo.mp4")} />
|
|
@@ -84,13 +84,13 @@ As new core components are released, which support referencing assets, we'll upd
|
|
|
84
84
|
|
|
85
85
|
## Getting Started
|
|
86
86
|
|
|
87
|
-
After you've created an account on [Source Push](https://console.srcpush.com/register), you can start
|
|
87
|
+
After you've created an account on [Source Push](https://console.srcpush.com/register), you can start Source Push-ifying your React Native app by running the following command from within your app's root directory:
|
|
88
88
|
|
|
89
89
|
```shell
|
|
90
90
|
npm install --save @srcpush/react-native-code-push
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
As with all other React Native plugins, the integration experience is different for iOS and Android, so perform the following setup steps depending on which platform(s) you are targeting. Note, if you are targeting both platforms it is recommended to create separate
|
|
93
|
+
As with all other React Native plugins, the integration experience is different for iOS and Android, so perform the following setup steps depending on which platform(s) you are targeting. Note, if you are targeting both platforms it is recommended to create separate Source Push applications for each platform.
|
|
94
94
|
|
|
95
95
|
*NOTE: This guide assumes you have used the `@react-native-community/cli init` command to initialize your React Native project.*
|
|
96
96
|
|
|
@@ -101,13 +101,13 @@ Then continue with installing the native module
|
|
|
101
101
|
|
|
102
102
|
## Plugin Usage
|
|
103
103
|
|
|
104
|
-
With the
|
|
104
|
+
With the Source Push plugin downloaded and linked, and your app asking Source Push where to get the right JS bundle from, the only thing left is to add the necessary code to your app to control the following policies:
|
|
105
105
|
|
|
106
106
|
1. When (and how often) to check for an update? (for example app start, in response to clicking a button in a settings page, periodically at some fixed interval)
|
|
107
107
|
|
|
108
108
|
2. When an update is available, how to present it to the end user?
|
|
109
109
|
|
|
110
|
-
The simplest way to do this is to "
|
|
110
|
+
The simplest way to do this is to "Source Push-ify" your app's root component. To do so, you can choose one of the following two options:
|
|
111
111
|
|
|
112
112
|
* **Option 1: Wrap your root component with the `codePush` higher-order component:**
|
|
113
113
|
|
package/SECURITY.md
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
|
|
2
|
-
|
|
3
1
|
## Security
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
Source Push takes the security of our software products and services seriously.
|
|
6
4
|
|
|
7
|
-
If you believe you have found a security vulnerability in
|
|
5
|
+
If you believe you have found a security vulnerability in this repository, please report it to us as described below.
|
|
8
6
|
|
|
9
7
|
## Reporting Security Issues
|
|
10
8
|
|
|
11
9
|
**Please do not report security vulnerabilities through public GitHub issues.**
|
|
12
10
|
|
|
13
|
-
Instead, please report them to
|
|
14
|
-
|
|
15
|
-
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
|
|
11
|
+
Instead, please report them to us via email at [security@srcpush.com](mailto:security@srcpush.com).
|
|
16
12
|
|
|
17
|
-
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
|
|
13
|
+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
|
|
18
14
|
|
|
19
15
|
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
|
20
16
|
|
|
@@ -26,16 +22,4 @@ Please include the requested information listed below (as much as you can provid
|
|
|
26
22
|
* Proof-of-concept or exploit code (if possible)
|
|
27
23
|
* Impact of the issue, including how an attacker might exploit the issue
|
|
28
24
|
|
|
29
|
-
This information will help us triage your report more quickly.
|
|
30
|
-
|
|
31
|
-
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
|
|
32
|
-
|
|
33
|
-
## Preferred Languages
|
|
34
|
-
|
|
35
|
-
We prefer all communications to be in English.
|
|
36
|
-
|
|
37
|
-
## Policy
|
|
38
|
-
|
|
39
|
-
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
|
|
40
|
-
|
|
41
|
-
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
|
25
|
+
This information will help us triage your report more quickly.
|
package/android/app/build.gradle
CHANGED
|
@@ -40,16 +40,6 @@ android {
|
|
|
40
40
|
defaultConfig {
|
|
41
41
|
consumerProguardFiles 'proguard-rules.pro'
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
sourceSets {
|
|
45
|
-
main {
|
|
46
|
-
if (IS_NEW_ARCHITECTURE_ENABLED) {
|
|
47
|
-
java.srcDirs += ['src/newarch/java']
|
|
48
|
-
} else {
|
|
49
|
-
java.srcDirs += ['src/oldarch/java']
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
43
|
}
|
|
54
44
|
|
|
55
45
|
dependencies {
|
|
@@ -46,7 +46,7 @@ import java.util.Map;
|
|
|
46
46
|
import java.util.UUID;
|
|
47
47
|
|
|
48
48
|
@OptIn(markerClass = UnstableReactNativeAPI.class)
|
|
49
|
-
public class CodePushNativeModule extends
|
|
49
|
+
public class CodePushNativeModule extends BaseJavaModule {
|
|
50
50
|
private String mBinaryContentsHash = null;
|
|
51
51
|
private String mClientUniqueId = null;
|
|
52
52
|
private LifecycleEventListener mLifecycleEventListener = null;
|
|
@@ -82,11 +82,6 @@ public class CodePushNativeModule extends CodePushNativeModuleSpec {
|
|
|
82
82
|
|
|
83
83
|
@Override
|
|
84
84
|
public Map<String, Object> getConstants() {
|
|
85
|
-
return getTypedExportedConstants();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@Override
|
|
89
|
-
public Map<String, Object> getTypedExportedConstants() {
|
|
90
85
|
final Map<String, Object> constants = new HashMap<>();
|
|
91
86
|
|
|
92
87
|
constants.put("codePushInstallModeImmediate", CodePushInstallMode.IMMEDIATE.getValue());
|
|
@@ -505,9 +500,8 @@ public class CodePushNativeModule extends CodePushNativeModuleSpec {
|
|
|
505
500
|
}
|
|
506
501
|
}
|
|
507
502
|
|
|
508
|
-
@Override
|
|
509
503
|
@ReactMethod
|
|
510
|
-
public void getUpdateMetadata(final
|
|
504
|
+
public void getUpdateMetadata(final int updateState, final Promise promise) {
|
|
511
505
|
AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() {
|
|
512
506
|
@Override
|
|
513
507
|
protected Void doInBackground(Void... params) {
|
|
@@ -526,11 +520,11 @@ public class CodePushNativeModule extends CodePushNativeModuleSpec {
|
|
|
526
520
|
currentUpdateIsPending = mSettingsManager.isPendingUpdate(currentHash);
|
|
527
521
|
}
|
|
528
522
|
|
|
529
|
-
if (
|
|
523
|
+
if (updateState == CodePushUpdateState.PENDING.getValue() && !currentUpdateIsPending) {
|
|
530
524
|
// The caller wanted a pending update
|
|
531
525
|
// but there isn't currently one.
|
|
532
526
|
promise.resolve(null);
|
|
533
|
-
} else if (
|
|
527
|
+
} else if (updateState == CodePushUpdateState.RUNNING.getValue() && currentUpdateIsPending) {
|
|
534
528
|
// The caller wants the running update, but the current
|
|
535
529
|
// one is pending, so we need to grab the previous.
|
|
536
530
|
JSONObject previousPackage = mUpdateManager.getPreviousPackage();
|
|
@@ -631,9 +625,8 @@ public class CodePushNativeModule extends CodePushNativeModuleSpec {
|
|
|
631
625
|
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
632
626
|
}
|
|
633
627
|
|
|
634
|
-
@Override
|
|
635
628
|
@ReactMethod
|
|
636
|
-
public void installUpdate(final ReadableMap updatePackage, final
|
|
629
|
+
public void installUpdate(final ReadableMap updatePackage, final int installMode, final int minimumBackgroundDuration, final Promise promise) {
|
|
637
630
|
AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() {
|
|
638
631
|
@Override
|
|
639
632
|
protected Void doInBackground(Void... params) {
|
|
@@ -647,17 +640,17 @@ public class CodePushNativeModule extends CodePushNativeModuleSpec {
|
|
|
647
640
|
mSettingsManager.savePendingUpdate(pendingHash, /* isLoading */false);
|
|
648
641
|
}
|
|
649
642
|
|
|
650
|
-
if (
|
|
643
|
+
if (installMode == CodePushInstallMode.ON_NEXT_RESUME.getValue() ||
|
|
651
644
|
// We also add the resume listener if the installMode is IMMEDIATE, because
|
|
652
645
|
// if the current activity is backgrounded, we want to reload the bundle when
|
|
653
646
|
// it comes back into the foreground.
|
|
654
|
-
|
|
655
|
-
|
|
647
|
+
installMode == CodePushInstallMode.IMMEDIATE.getValue() ||
|
|
648
|
+
installMode == CodePushInstallMode.ON_NEXT_SUSPEND.getValue()) {
|
|
656
649
|
|
|
657
650
|
// Store the minimum duration on the native module as an instance
|
|
658
651
|
// variable instead of relying on a closure below, so that any
|
|
659
652
|
// subsequent resume-based installs could override it.
|
|
660
|
-
CodePushNativeModule.this.mMinimumBackgroundDuration =
|
|
653
|
+
CodePushNativeModule.this.mMinimumBackgroundDuration = minimumBackgroundDuration;
|
|
661
654
|
|
|
662
655
|
if (mLifecycleEventListener == null) {
|
|
663
656
|
// Ensure we do not add the listener twice.
|
|
@@ -679,7 +672,7 @@ public class CodePushNativeModule extends CodePushNativeModuleSpec {
|
|
|
679
672
|
// the foreground, so explicitly wait for it to be backgrounded first
|
|
680
673
|
if (lastPausedDate != null) {
|
|
681
674
|
long durationInBackground = (new Date().getTime() - lastPausedDate.getTime()) / 1000;
|
|
682
|
-
if (
|
|
675
|
+
if (installMode == CodePushInstallMode.IMMEDIATE.getValue()
|
|
683
676
|
|| durationInBackground >= CodePushNativeModule.this.mMinimumBackgroundDuration) {
|
|
684
677
|
CodePushUtils.log("Loading bundle on resume");
|
|
685
678
|
restartAppInternal(false);
|
|
@@ -693,8 +686,8 @@ public class CodePushNativeModule extends CodePushNativeModuleSpec {
|
|
|
693
686
|
// resumed, we can detect how long it was in the background.
|
|
694
687
|
lastPausedDate = new Date();
|
|
695
688
|
|
|
696
|
-
if (
|
|
697
|
-
appSuspendHandler.postDelayed(loadBundleRunnable,
|
|
689
|
+
if (installMode == CodePushInstallMode.ON_NEXT_SUSPEND.getValue() && mSettingsManager.isPendingUpdate(null)) {
|
|
690
|
+
appSuspendHandler.postDelayed(loadBundleRunnable, minimumBackgroundDuration * 1000);
|
|
698
691
|
}
|
|
699
692
|
}
|
|
700
693
|
|
|
@@ -707,11 +700,7 @@ public class CodePushNativeModule extends CodePushNativeModuleSpec {
|
|
|
707
700
|
}
|
|
708
701
|
}
|
|
709
702
|
|
|
710
|
-
|
|
711
|
-
loadBundle();
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
promise.resolve(null);
|
|
703
|
+
promise.resolve("");
|
|
715
704
|
} catch(CodePushUnknownException e) {
|
|
716
705
|
CodePushUtils.log(e);
|
|
717
706
|
promise.reject(e);
|
|
@@ -833,15 +822,13 @@ public class CodePushNativeModule extends CodePushNativeModuleSpec {
|
|
|
833
822
|
mCodePush.clearUpdates();
|
|
834
823
|
}
|
|
835
824
|
|
|
836
|
-
@Override
|
|
837
825
|
@ReactMethod
|
|
838
826
|
public void addListener(String eventName) {
|
|
839
827
|
// Set up any upstream listeners or background tasks as necessary
|
|
840
828
|
}
|
|
841
829
|
|
|
842
|
-
@Override
|
|
843
830
|
@ReactMethod
|
|
844
|
-
public void removeListeners(
|
|
831
|
+
public void removeListeners(Integer count) {
|
|
845
832
|
// Remove upstream listeners, stop unnecessary background tasks
|
|
846
833
|
}
|
|
847
834
|
|
package/docs/api-android.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
### Resource Configuration
|
|
2
2
|
|
|
3
|
-
Since `autolinking` uses `react-native.config.js` to link plugins, constructors are specified in that file. But you can override custom variables to manage the
|
|
3
|
+
Since `autolinking` uses `react-native.config.js` to link plugins, constructors are specified in that file. But you can override custom variables to manage the Source Push plugin by placing these values in string resources.
|
|
4
4
|
|
|
5
5
|
- **Public Key** - used for bundle verification in the Code Signing Feature. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature.
|
|
6
|
-
To set the public key, you should add the content of the public key to `strings.xml` with name `CodePushPublicKey`.
|
|
6
|
+
To set the public key, you should add the content of the public key to `strings.xml` with name `CodePushPublicKey`. Source Push automatically gets this property and enables the Code Signing feature. For example:
|
|
7
7
|
|
|
8
8
|
```xml
|
|
9
9
|
<string moduleConfig="true" name="CodePushPublicKey">your-public-key</string>
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
- **Server Url** - used for specifying
|
|
13
|
-
The Default value: "<https://api.srcpush.com>" is overridden by adding your path to `strings.xml` with name `CodePushServerUrl`.
|
|
12
|
+
- **Server Url** - used for specifying Source Push Server Url.
|
|
13
|
+
The Default value: "<https://api.srcpush.com>" is overridden by adding your path to `strings.xml` with name `CodePushServerUrl`. Source Push automatically gets this property and will use this path to send requests. For example:
|
|
14
14
|
|
|
15
15
|
```xml
|
|
16
16
|
<string moduleConfig="true" name="CodePushServerUrl">https://api.srcpush.com</string>
|
|
@@ -22,21 +22,21 @@ The Java API is made available by importing the `com.microsoft.codepush.react.Co
|
|
|
22
22
|
|
|
23
23
|
#### CodePush
|
|
24
24
|
|
|
25
|
-
Constructs the
|
|
25
|
+
Constructs the Source Push client runtime and represents the `ReactPackage` instance that you add to you app's list of packages.
|
|
26
26
|
|
|
27
27
|
##### Constructors
|
|
28
28
|
|
|
29
|
-
- **CodePush(String deploymentKey, Activity mainActivity)** - Creates a new instance of the
|
|
29
|
+
- **CodePush(String deploymentKey, Activity mainActivity)** - Creates a new instance of the Source Push runtime, that will be used to query the service for updates via the provided deployment key. The `mainActivity` parameter should always be set to `this` when configuring your React packages list inside the `MainActivity` class. This constructor puts the Source Push runtime into "release mode", so if you want to enable debugging behavior, use the following constructor instead.
|
|
30
30
|
|
|
31
|
-
- **CodePush(String deploymentKey, Activity mainActivity, bool isDebugMode)** - Equivalent to the previous constructor but allows you to specify whether you want the
|
|
31
|
+
- **CodePush(String deploymentKey, Activity mainActivity, bool isDebugMode)** - Equivalent to the previous constructor but allows you to specify whether you want the Source Push runtime to be in debug mode or not. When using this constructor, the `isDebugMode` parameter should always be set to `BuildConfig.DEBUG` in order to stay synchronized with your build type. When putting Source Push into debug mode, the following behaviors are enabled:
|
|
32
32
|
|
|
33
|
-
1. Old
|
|
33
|
+
1. Old Source Push updates aren't deleted from storage whenever a new binary is deployed to the emulator/device. This behavior enables you to deploy new binaries, without bumping the version during development, and without continuously getting the same update every time your app calls `sync`.
|
|
34
34
|
|
|
35
|
-
2. The local cache that the React Native runtime maintains in debug mode is deleted whenever a
|
|
35
|
+
2. The local cache that the React Native runtime maintains in debug mode is deleted whenever a Source Push update is installed. This ensures that when the app is restarted after an update is applied, you will see the expected changes. As soon as [this PR](https://github.com/facebook/react-native/pull/4738) is merged, we won't need to do this anymore.
|
|
36
36
|
|
|
37
37
|
- **CodePush(String deploymentKey, Context context, boolean isDebugMode, Integer publicKeyResourceDescriptor)** - Equivalent to the previous constructor, but allows you to specify the public key resource descriptor needed to read public key content. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature.
|
|
38
38
|
|
|
39
|
-
- **CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl)** Constructor allows you to specify
|
|
39
|
+
- **CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl)** Constructor allows you to specify Source Push Server Url. The Default value: `"https://api.srcpush.com"` is overridden by value specified in `serverUrl`.
|
|
40
40
|
|
|
41
41
|
##### Public Methods
|
|
42
42
|
|
package/docs/api-ios.md
CHANGED
|
@@ -8,15 +8,15 @@ Contains static methods for retreiving the `NSURL` that represents the most rece
|
|
|
8
8
|
|
|
9
9
|
The `CodePush` class' methods can be thought of as composite resolvers which always load the appropriate bundle, in order to accommodate the following scenarios:
|
|
10
10
|
|
|
11
|
-
1. When an end-user installs your app from the store (like `1.0.0`), they will get the JS bundle that is contained within the binary. This is the behavior you would get without using
|
|
11
|
+
1. When an end-user installs your app from the store (like `1.0.0`), they will get the JS bundle that is contained within the binary. This is the behavior you would get without using Source Push, but we make sure it doesn't break :)
|
|
12
12
|
|
|
13
|
-
2. As soon as you begin releasing
|
|
13
|
+
2. As soon as you begin releasing Source Push updates, your end-users will get the JS bundle that represents the latest release for the configured deployment. This is the behavior that allows you to iterate beyond what you shipped to the store.
|
|
14
14
|
|
|
15
|
-
3. As soon as you release an update to the app store (like `1.1.0`), and your end-users update it, they will once again get the JS bundle that is contained within the binary. This behavior ensures that
|
|
15
|
+
3. As soon as you release an update to the app store (like `1.1.0`), and your end-users update it, they will once again get the JS bundle that is contained within the binary. This behavior ensures that Source Push updates that targetted a previous binary version aren't used (since we don't know if they would work), and your end-users always have a working version of your app.
|
|
16
16
|
|
|
17
|
-
4. Repeat #2 and #3 as the
|
|
17
|
+
4. Repeat #2 and #3 as the Source Push releases and app store releases continue on into infinity (and beyond?)
|
|
18
18
|
|
|
19
|
-
Because of this behavior, you can safely deploy updates to both the app store(s) and
|
|
19
|
+
Because of this behavior, you can safely deploy updates to both the app store(s) and Source Push as necesary, and rest assured that your end-users will always get the most recent version.
|
|
20
20
|
|
|
21
21
|
##### Methods
|
|
22
22
|
|
package/docs/api-js.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## API Reference
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Source Push plugin is made up of two components:
|
|
4
4
|
|
|
5
5
|
1. A JavaScript module, which can be imported/required, and allows the app to interact with the service during runtime (for example check for updates, inspect the metadata about the currently running app update).
|
|
6
6
|
|
|
@@ -14,23 +14,23 @@ When you require `react-native-code-push`, the module object provides the follow
|
|
|
14
14
|
|
|
15
15
|
* [allowRestart](#codepushallowrestart): Re-allows programmatic restarts to occur as a result of an update being installed, and optionally, immediately restarts the app if a pending update had attempted to restart the app while restarts were disallowed. This is an advanced API and is only necessary if your app explicitly disallowed restarts via the `disallowRestart` method.
|
|
16
16
|
|
|
17
|
-
* [checkForUpdate](#codepushcheckforupdate): Asks the
|
|
17
|
+
* [checkForUpdate](#codepushcheckforupdate): Asks the Source Push service whether the configured app deployment has an update available.
|
|
18
18
|
|
|
19
|
-
* [disallowRestart](#codepushdisallowrestart): Temporarily disallows any programmatic restarts to occur as a result of a
|
|
19
|
+
* [disallowRestart](#codepushdisallowrestart): Temporarily disallows any programmatic restarts to occur as a result of a Source Push update being installed. This is an advanced API, and is useful when a component within your app (for example an onboarding process) needs to ensure that no end-user interruptions can occur during its lifetime.
|
|
20
20
|
|
|
21
|
-
* [getCurrentPackage](#codepushgetcurrentpackage): Retrieves the metadata about the currently installed update (like description, installation time, size). *NOTE: As of `v1.10.3-beta` of the
|
|
21
|
+
* [getCurrentPackage](#codepushgetcurrentpackage): Retrieves the metadata about the currently installed update (like description, installation time, size). *NOTE: As of `v1.10.3-beta` of the Source Push module, this method is deprecated in favor of [`getUpdateMetadata`](#codepushgetupdatemetadata)*.
|
|
22
22
|
|
|
23
23
|
* [getUpdateMetadata](#codepushgetupdatemetadata): Retrieves the metadata for an installed update (like description, mandatory).
|
|
24
24
|
|
|
25
|
-
* [notifyAppReady](#codepushnotifyappready): Notifies the
|
|
25
|
+
* [notifyAppReady](#codepushnotifyappready): Notifies the Source Push runtime that an installed update is considered successful. If you are manually checking for and installing updates (i.e. not using the [sync](#codepushsync) method to handle it all for you), then this method **MUST** be called; otherwise Source Push will treat the update as failed and rollback to the previous version when the app next restarts.
|
|
26
26
|
|
|
27
27
|
* [restartApp](#codepushrestartapp): Immediately restarts the app. If there is an update pending, it will be immediately displayed to the end user. Otherwise, calling this method simply has the same behavior as the end user killing and restarting the process.
|
|
28
28
|
|
|
29
|
-
* [sync](#codepushsync): Allows checking for an update, downloading it and installing it, all with a single call. Unless you need custom UI and/or behavior, we recommend most developers to use this method when integrating
|
|
29
|
+
* [sync](#codepushsync): Allows checking for an update, downloading it and installing it, all with a single call. Unless you need custom UI and/or behavior, we recommend most developers to use this method when integrating Source Push into their apps
|
|
30
30
|
|
|
31
|
-
* [clearUpdates](#clearupdates): Clear all downloaded
|
|
31
|
+
* [clearUpdates](#clearupdates): Clear all downloaded Source Push updates. This is useful when switching to a different deployment which may have an older release than the current package.
|
|
32
32
|
|
|
33
|
-
_Note: we don’t recommend to use this method in scenarios other than that (
|
|
33
|
+
_Note: we don’t recommend to use this method in scenarios other than that (Source Push will call this method automatically when needed in other cases) as it could lead to unpredictable behavior._
|
|
34
34
|
|
|
35
35
|
#### codePush
|
|
36
36
|
|
|
@@ -162,7 +162,7 @@ Called when the sync process moves from one stage to another in the overall upda
|
|
|
162
162
|
|
|
163
163
|
##### codePushDownloadDidProgress (event hook)
|
|
164
164
|
|
|
165
|
-
Called periodically when an available update is being downloaded from the
|
|
165
|
+
Called periodically when an available update is being downloaded from the Source Push server. The method is called with a `DownloadProgress` object, which contains the following two properties:
|
|
166
166
|
|
|
167
167
|
* __totalBytes__ *(Number)* - The total number of bytes expected to be received for this update (i.e. the size of the set of files which changed from the previous release).
|
|
168
168
|
|
|
@@ -176,15 +176,15 @@ codePush.allowRestart(): void;
|
|
|
176
176
|
|
|
177
177
|
Re-allows programmatic restarts to occur, that would have otherwise been rejected due to a previous call to `disallowRestart`. If `disallowRestart` was never called in the first place, then calling this method will simply result in a no-op.
|
|
178
178
|
|
|
179
|
-
If a
|
|
179
|
+
If a Source Push update is currently pending, which attempted to restart the app (for example it used `InstallMode.IMMEDIATE`), but was blocked due to `disallowRestart` having been called, then calling `allowRestart` will result in an immediate restart. This allows the update to be applied as soon as possible, without interrupting the end user during critical workflows (for example an onboarding process).
|
|
180
180
|
|
|
181
181
|
For example, calling `allowRestart` would trigger an immediate restart if either of the three scenarios mentioned in the [`disallowRestart` docs](#codepushdisallowrestart) occured after `disallowRestart` was called. However, calling `allowRestart` wouldn't trigger a restart if the following were true:
|
|
182
182
|
|
|
183
|
-
1. No
|
|
183
|
+
1. No Source Push updates were installed since the last time `disallowRestart` was called, and therefore, there isn't any need to restart anyways.
|
|
184
184
|
|
|
185
|
-
2. There is currently a pending
|
|
185
|
+
2. There is currently a pending Source Push update, but it was installed via `InstallMode.ON_NEXT_RESTART`, and therefore, doesn't require a programmatic restart.
|
|
186
186
|
|
|
187
|
-
3. There is currently a pending
|
|
187
|
+
3. There is currently a pending Source Push update, but it was installed via `InstallMode.ON_NEXT_RESUME` and the app hasn't been put into the background yet, and therefore, there isn't a need to programmatically restart yet.
|
|
188
188
|
|
|
189
189
|
4. No calls to `restartApp` were made since the last time `disallowRestart` was called.
|
|
190
190
|
|
|
@@ -198,7 +198,7 @@ See [disallowRestart](#codepushdisallowrestart) for an example of how this metho
|
|
|
198
198
|
codePush.checkForUpdate(deploymentKey: String = null, handleBinaryVersionMismatchCallback: (update: RemotePackage) => void): Promise<RemotePackage>;
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
-
Queries the
|
|
201
|
+
Queries the Source Push service to see whether the configured app deployment has an update available. By default, it will use the deployment key that is configured in your `Info.plist` file (iOS), or `MainActivity.java` file (Android), but you can override that by specifying a value via the optional `deploymentKey` parameter. This can be useful when you want to dynamically "redirect" a user to a specific deployment, such as allowing "early access" via an easter egg or a user setting switch.
|
|
202
202
|
|
|
203
203
|
Second optional parameter `handleBinaryVersionMismatchCallback` is an optional callback function that can be used to notify user if there are any binary update.
|
|
204
204
|
E.g. consider a use-case where currently installed binary version is 1.0.1 with label(codepush label) v1. Later native code was changed in the dev cycle and binary version was updated to 1.0.2. When code-push update check is triggered we ignore updates having binary version mismatch (because the update is not targeting to the binary version of currently installed app). In this case installed app (1.0.1) will ignore the update targeting version 1.0.2. You can use `handleBinaryVersionMismatchCallback` to provide a hook to handle such situations.
|
|
@@ -240,15 +240,15 @@ codePush.disallowRestart(): void;
|
|
|
240
240
|
|
|
241
241
|
Temporarily disallows programmatic restarts to occur as a result of either of following scenarios:
|
|
242
242
|
|
|
243
|
-
1. A
|
|
244
|
-
2. A
|
|
243
|
+
1. A Source Push update is installed using `InstallMode.IMMEDIATE`
|
|
244
|
+
2. A Source Push update is installed using `InstallMode.ON_NEXT_RESUME` and the app is resumed from the background (optionally being throttled by the `minimumBackgroundDuration` property)
|
|
245
245
|
3. The `restartApp` method was called
|
|
246
246
|
|
|
247
247
|
*NOTE: #1 and #2 effectively work by calling `restartApp` for you, so you can think of `disallowRestart` as blocking any call to `restartApp`, regardless if your app calls it directly or indirectly.*
|
|
248
248
|
|
|
249
249
|
After calling this method, any calls to `sync` would still be allowed to check for an update, download it and install it, but an attempt to restart the app would be queued until `allowRestart` is called. This way, the restart request is captured and can be "flushed" whenever you want to allow it to occur.
|
|
250
250
|
|
|
251
|
-
This is an advanced API, and is primarily useful when individual components within your app (like an onboarding process) need to ensure that no end-user interruptions can occur during their lifetime, while continuing to allow the app to keep syncing with the
|
|
251
|
+
This is an advanced API, and is primarily useful when individual components within your app (like an onboarding process) need to ensure that no end-user interruptions can occur during their lifetime, while continuing to allow the app to keep syncing with the Source Push server at its own pace and using whatever install modes are appropriate. This has the benefit of allowing the app to discover and download available updates as soon as possible, while also preventing any disruptions during key end-user experiences.
|
|
252
252
|
|
|
253
253
|
As an alternative, you could also choose to simply use `InstallMode.ON_NEXT_RESTART` whenever calling `sync` (which will never attempt to programmatically restart the app), and then explicity calling `restartApp` at points in your app that you know it is "safe" to do so. `disallowRestart` provides an alternative approach to this when the code that synchronizes with the CodePush server is separate from the code/components that want to enforce a no-restart policy.
|
|
254
254
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
>
|
|
5
5
|
> Complete demo configured with "multi-deployment testing" feature is [here](https://github.com/microsoft/react-native-code-push/files/1314118/rncp1004.zip).
|
|
6
6
|
|
|
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
|
|
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 Source Push staging deployment key and your release builds to use your Source Push production deployment key.
|
|
8
8
|
|
|
9
9
|
*NOTE: As a reminder, you can retrieve these keys by running `srcpush deployment ls <appName> -k` from your terminal.*
|
|
10
10
|
|
|
@@ -22,7 +22,7 @@ To set this up, perform the following steps:
|
|
|
22
22
|
buildTypes {
|
|
23
23
|
debug {
|
|
24
24
|
...
|
|
25
|
-
// Note:
|
|
25
|
+
// Note: Source Push updates should not be tested in Debug mode as they are overriden by the RN packager. However, because Source Push checks for updates in all modes, we must supply a key.
|
|
26
26
|
resValue "string", "CodePushDeploymentKey", '""'
|
|
27
27
|
...
|
|
28
28
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
> * **without using cocoa pods**: [link](https://github.com/microsoft/react-native-code-push/files/1259957/rncp976.copy.zip)
|
|
8
8
|
> * **using cocoa pods**: [link](https://github.com/microsoft/react-native-code-push/files/1172217/rncp893.copy.zip)
|
|
9
9
|
|
|
10
|
-
Xcode allows you to define custom build settings for each "configuration" (like debug, release), which can then be referenced as the value of keys within the `Info.plist` file (like the `CodePushDeploymentKey` setting). This mechanism allows you to easily configure your builds to produce binaries, which are configured to synchronize with different
|
|
10
|
+
Xcode allows you to define custom build settings for each "configuration" (like debug, release), which can then be referenced as the value of keys within the `Info.plist` file (like the `CodePushDeploymentKey` setting). This mechanism allows you to easily configure your builds to produce binaries, which are configured to synchronize with different Source Push deployments.
|
|
11
11
|
|
|
12
12
|
To set this up, perform the following steps:
|
|
13
13
|
|
package/docs/setup-android.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* [Plugin Installation and Configuration for React Native 0.76 version and above](#plugin-installation-and-configuration-for-react-native-060-version-and-above-android)
|
|
4
4
|
* [Code Signing setup](#code-signing-setup)
|
|
5
5
|
|
|
6
|
-
In order to integrate
|
|
6
|
+
In order to integrate Source Push into your Android project, please perform the following steps:
|
|
7
7
|
|
|
8
8
|
### Plugin Installation and Configuration for React Native 0.76 version and above (Android)
|
|
9
9
|
|
|
@@ -15,7 +15,7 @@ In order to integrate CodePush into your Android project, please perform the fol
|
|
|
15
15
|
...
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
2. Update the `MainApplication` file to use
|
|
18
|
+
2. Update the `MainApplication` file to use Source Push via the following changes:
|
|
19
19
|
|
|
20
20
|
For React Native 0.76 and above: update the `MainApplication.kt`
|
|
21
21
|
|
|
@@ -35,7 +35,7 @@ In order to integrate CodePush into your Android project, please perform the fol
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// 2. Override the getJSBundleFile method in order to let
|
|
38
|
-
// the
|
|
38
|
+
// the Source Push runtime determine where to get the JS
|
|
39
39
|
// bundle location from on each app start
|
|
40
40
|
override fun getJSBundleFile(): String {
|
|
41
41
|
return CodePush.getJSBundleFile()
|
|
@@ -46,7 +46,7 @@ In order to integrate CodePush into your Android project, please perform the fol
|
|
|
46
46
|
|
|
47
47
|
3. Add the Deployment key to `strings.xml`:
|
|
48
48
|
|
|
49
|
-
To let the
|
|
49
|
+
To let the Source Push runtime know which deployment it should query for updates, open your app's `strings.xml` file and
|
|
50
50
|
add a new string named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against
|
|
51
51
|
(like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `srcpush deployment ls <appName> -k`
|
|
52
52
|
in the Source Push CLI (the `-k` or `--displayKeys` flag is necessary since keys aren't displayed by default) or take in [Source Push UI](https://console.srcpush.com/applications)
|
|
@@ -55,7 +55,7 @@ The "friendly name" is intended only for authenticated management usage from the
|
|
|
55
55
|
|
|
56
56
|

|
|
57
57
|
|
|
58
|
-
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your
|
|
58
|
+
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your Source Push app, refer to the [multi-deployment testing](../README.md#multi-deployment-testing) docs below before actually moving your app's usage of Source Push into production.
|
|
59
59
|
|
|
60
60
|
Your `strings.xml` should look like this:
|
|
61
61
|
|
|
@@ -68,11 +68,11 @@ The "friendly name" is intended only for authenticated management usage from the
|
|
|
68
68
|
|
|
69
69
|
*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)*
|
|
70
70
|
|
|
71
|
-
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your
|
|
71
|
+
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your Source Push app, refer to the [multi-deployment testing](../README.md#multi-deployment-testing) docs below before actually moving your app's usage of Source Push into production.
|
|
72
72
|
|
|
73
73
|
### Code Signing setup
|
|
74
74
|
|
|
75
|
-
You can self sign bundles during release and verify its signature before installation of update. For more info about Code Signing please refer to [relevant
|
|
75
|
+
You can self sign bundles during release and verify its signature before installation of update. For more info about Code Signing please refer to [relevant Source Push documentation section](https://docs.srcpush.com).
|
|
76
76
|
In order to use Public Key for Code Signing you need to do following steps:
|
|
77
77
|
|
|
78
78
|
Add `CodePushPublicKey` string item to `/path_to_your_app/android/app/src/main/res/values/strings.xml`. It may look like this:
|
package/docs/setup-ios.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## iOS Setup
|
|
2
2
|
|
|
3
|
-
Once you've acquired the
|
|
3
|
+
Once you've acquired the Source Push plugin, you need to integrate it into the Xcode project of your React Native app and configure it correctly. To do this, take the following steps:
|
|
4
4
|
|
|
5
5
|
### Plugin Installation and Configuration for React Native 0.76 version and above (iOS)
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ Once you've acquired the CodePush plugin, you need to integrate it into the Xcod
|
|
|
9
9
|
2. Change bundleUrl on AppDelegate file.
|
|
10
10
|
|
|
11
11
|
**If you're using objective-c:**
|
|
12
|
-
1. Open up the `AppDelegate.m` file, and add an import statement for the
|
|
12
|
+
1. Open up the `AppDelegate.m` file, and add an import statement for the Source Push headers:
|
|
13
13
|
|
|
14
14
|
```objective-c
|
|
15
15
|
#import <CodePush/CodePush.h>
|
|
@@ -27,11 +27,11 @@ Once you've acquired the CodePush plugin, you need to integrate it into the Xcod
|
|
|
27
27
|
return [CodePush bundleURL];
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
This change configures your app to always load the most recent version of your app's JS bundle. On the first launch, this will correspond to the file that was compiled with the app. However, after an update has been pushed via
|
|
30
|
+
This change configures your app to always load the most recent version of your app's JS bundle. On the first launch, this will correspond to the file that was compiled with the app. However, after an update has been pushed via Source Push, this will return the location of the most recently installed update.
|
|
31
31
|
|
|
32
32
|
*NOTE: The `bundleURL` method assumes your app's JS bundle is named `main.jsbundle`. If you have configured your app to use a different file name, simply call the `bundleURLForResource:` method (which assumes you're using the `.jsbundle` extension) or `bundleURLForResource:withExtension:` method instead, in order to overwrite that default behavior*
|
|
33
33
|
|
|
34
|
-
Typically, you're only going to want to use
|
|
34
|
+
Typically, you're only going to want to use Source Push to resolve your JS bundle location within release builds, and therefore, we recommend using the `DEBUG` pre-processor macro to dynamically switch between using the packager server and Source Push, depending on whether you are debugging or not. This will make it much simpler to ensure you get the right behavior you want in production, while still being able to use the Chrome Dev Tools, live reload, etc. at debug-time.
|
|
35
35
|
|
|
36
36
|
Your `sourceURLForBridge` method should look like this:
|
|
37
37
|
|
|
@@ -47,7 +47,7 @@ Once you've acquired the CodePush plugin, you need to integrate it into the Xcod
|
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
**If you're using Swift:**
|
|
50
|
-
1. Open up the `AppDelegate.swift` file, and add an import statement for the
|
|
50
|
+
1. Open up the `AppDelegate.swift` file, and add an import statement for the Source Push headers:
|
|
51
51
|
|
|
52
52
|
```swift
|
|
53
53
|
import CodePush
|
|
@@ -79,20 +79,20 @@ Once you've acquired the CodePush plugin, you need to integrate it into the Xcod
|
|
|
79
79
|
|
|
80
80
|
4. Add the Deployment key to `Info.plist`:
|
|
81
81
|
|
|
82
|
-
To let the
|
|
82
|
+
To let the Source Push runtime know which deployment it should query for updates against, open your app's `Info.plist`
|
|
83
83
|
file and add a new entry named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure
|
|
84
84
|
this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `srcpush deployment ls <appName> -k` in the Source Push CLI (the `-k` or `--displayKeys` flag is necessary since keys aren't displayed by default) or take in [Source Push UI](https://console.srcpush.com/applications) 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.
|
|
85
85
|
That "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app.
|
|
86
86
|
|
|
87
87
|

|
|
88
88
|
|
|
89
|
-
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your
|
|
89
|
+
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your Source Push app, refer to the [multi-deployment testing](../README.md#multi-deployment-testing) docs below before actually moving your app's usage of Source Push into production.
|
|
90
90
|
|
|
91
91
|
*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)*
|
|
92
92
|
|
|
93
93
|
### HTTP exception domains configuration (iOS)
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
Source Push plugin makes HTTPS requests to the following domains:
|
|
96
96
|
|
|
97
97
|
- api.srcpush.com
|
|
98
98
|
- blob.srcpush.com
|
|
@@ -124,7 +124,7 @@ Before doing anything, please [read the docs][ats] first.
|
|
|
124
124
|
|
|
125
125
|
### Code Signing setup
|
|
126
126
|
|
|
127
|
-
You can self sign bundles during release and verify its signature before installation of update. For more info about Code Signing please refer to [relevant
|
|
127
|
+
You can self sign bundles during release and verify its signature before installation of update. For more info about Code Signing please refer to [relevant Source Push documentation section](https://docs.srcpush.com).
|
|
128
128
|
|
|
129
129
|
In order to configure Public Key for bundle verification you need to add record in `Info.plist` with name `CodePushPublicKey` and string value of public key content. Example:
|
|
130
130
|
|
package/docs/setup-windows.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
## Windows Setup
|
|
2
2
|
|
|
3
|
-
Once you've acquired the
|
|
3
|
+
Once you've acquired the Source Push plugin, you need to integrate it into the Visual Studio project of your React Native app and configure it correctly. To do this, take the following steps:
|
|
4
4
|
|
|
5
5
|
### Plugin Installation and Configuration for React Native Windows 0.63.6 version and above
|
|
6
6
|
|
|
7
7
|
#### Plugin Installation (Windows-npx)
|
|
8
8
|
|
|
9
|
-
Once the plugin has been downloaded, run `npx react-native autolink-windows` in your application's root directory to automatically add the
|
|
9
|
+
Once the plugin has been downloaded, run `npx react-native autolink-windows` in your application's root directory to automatically add the Source Push c++ project to your application's windows solution file.
|
|
10
10
|
|
|
11
11
|
#### Plugin Configuration (Windows)
|
|
12
12
|
|
|
@@ -78,7 +78,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
|
|
|
78
78
|
|
|
79
79
|
#### Plugin Configuration (Windows)
|
|
80
80
|
|
|
81
|
-
After installing the plugin, you need to configure your app to consult
|
|
81
|
+
After installing the plugin, you need to configure your app to consult Source Push for the location of your JS bundle, since it will "take control" of managing the current and all future versions. To do this, update the `MainReactNativeHost.cs` file to use Source Push via the following changes:
|
|
82
82
|
|
|
83
83
|
```c#
|
|
84
84
|
...
|
|
@@ -90,10 +90,10 @@ class MainReactNativeHost : ReactNativeHost
|
|
|
90
90
|
// 2. Declare a private instance variable for the CodePushModule instance.
|
|
91
91
|
private CodePushReactPackage codePushReactPackage;
|
|
92
92
|
|
|
93
|
-
// 3. Update the JavaScriptBundleFile property to initalize the
|
|
93
|
+
// 3. Update the JavaScriptBundleFile property to initalize the Source Push runtime,
|
|
94
94
|
// specifying the right deployment key, then use it to return the bundle URL from
|
|
95
|
-
//
|
|
96
|
-
// deployment key, you can run "
|
|
95
|
+
// Source Push instead of statically from the binary. If you don't already have your
|
|
96
|
+
// deployment key, you can run "srcpush deployment ls <appName> -k" to retrieve it.
|
|
97
97
|
protected override string JavaScriptBundleFile
|
|
98
98
|
{
|
|
99
99
|
get
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srcpush/react-native-code-push",
|
|
3
|
-
"version": "1.0.3-
|
|
3
|
+
"version": "1.0.3-main.1",
|
|
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",
|
|
@@ -81,13 +81,5 @@
|
|
|
81
81
|
"postlink": "node node_modules/@srcpush/react-native-code-push/scripts/postlink/run",
|
|
82
82
|
"postunlink": "node node_modules/@srcpush/react-native-code-push/scripts/postunlink/run"
|
|
83
83
|
}
|
|
84
|
-
},
|
|
85
|
-
"codegenConfig": {
|
|
86
|
-
"name": "RNCodePush",
|
|
87
|
-
"type": "modules",
|
|
88
|
-
"jsSrcsDir": "src",
|
|
89
|
-
"android": {
|
|
90
|
-
"javaPackageName": "com.microsoft.codepush.react"
|
|
91
|
-
}
|
|
92
84
|
}
|
|
93
85
|
}
|
package/android/app/src/newarch/java/com/microsoft/codepush/react/CodePushNativeModuleSpec.java
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
package com.microsoft.codepush.react;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
-
|
|
5
|
-
public abstract class CodePushNativeModuleSpec extends NativeRNCodePushSpec {
|
|
6
|
-
public CodePushNativeModuleSpec(ReactApplicationContext reactContext) {
|
|
7
|
-
super(reactContext);
|
|
8
|
-
}
|
|
9
|
-
}
|
package/android/app/src/oldarch/java/com/microsoft/codepush/react/CodePushNativeModuleSpec.java
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
package com.microsoft.codepush.react;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
5
|
-
import com.facebook.react.bridge.Promise;
|
|
6
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
7
|
-
|
|
8
|
-
public abstract class CodePushNativeModuleSpec extends ReactContextBaseJavaModule {
|
|
9
|
-
public CodePushNativeModuleSpec(ReactApplicationContext reactContext) {
|
|
10
|
-
super(reactContext);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public abstract void allow(Promise promise);
|
|
14
|
-
public abstract void clearPendingRestart(Promise promise);
|
|
15
|
-
public abstract void disallow(Promise promise);
|
|
16
|
-
public abstract void restartApp(boolean onlyIfUpdateIsPending, Promise promise);
|
|
17
|
-
public abstract void downloadUpdate(ReadableMap updatePackage, boolean notifyProgress, Promise promise);
|
|
18
|
-
public abstract void getConfiguration(Promise promise);
|
|
19
|
-
public abstract void getUpdateMetadata(double updateState, Promise promise);
|
|
20
|
-
public abstract void getNewStatusReport(Promise promise);
|
|
21
|
-
public abstract void installUpdate(ReadableMap updatePackage, double installMode, double minimumBackgroundDuration, Promise promise);
|
|
22
|
-
public abstract void isFailedUpdate(String packageHash, Promise promise);
|
|
23
|
-
public abstract void isFirstRun(String packageHash, Promise promise);
|
|
24
|
-
public abstract void notifyApplicationReady(Promise promise);
|
|
25
|
-
public abstract void recordStatusReported(ReadableMap statusReport);
|
|
26
|
-
public abstract void saveStatusReportForRetry(ReadableMap statusReport);
|
|
27
|
-
public abstract void downloadAndReplaceCurrentBundle(String remoteBundleUrl);
|
|
28
|
-
public abstract void clearUpdates();
|
|
29
|
-
public abstract void getLatestRollbackInfo(Promise promise);
|
|
30
|
-
public abstract void setLatestRollbackInfo(String packageHash, Promise promise);
|
|
31
|
-
public abstract void addListener(String eventName);
|
|
32
|
-
public abstract void removeListeners(double count);
|
|
33
|
-
public abstract java.util.Map<String, Object> getTypedExportedConstants();
|
|
34
|
-
}
|
package/src/NativeCodePush.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { TurboModule } from 'react-native';
|
|
2
|
-
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export interface Spec extends TurboModule {
|
|
5
|
-
getConstants(): {
|
|
6
|
-
codePushInstallModeImmediate: number;
|
|
7
|
-
codePushInstallModeOnNextRestart: number;
|
|
8
|
-
codePushInstallModeOnNextResume: number;
|
|
9
|
-
codePushInstallModeOnNextSuspend: number;
|
|
10
|
-
codePushUpdateStateRunning: number;
|
|
11
|
-
codePushUpdateStatePending: number;
|
|
12
|
-
codePushUpdateStateLatest: number;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
allow(): Promise<void>;
|
|
16
|
-
clearPendingRestart(): Promise<void>;
|
|
17
|
-
disallow(): Promise<void>;
|
|
18
|
-
restartApp(onlyIfUpdateIsPending: boolean): Promise<void>;
|
|
19
|
-
downloadUpdate(updatePackage: Object, notifyProgress: boolean): Promise<Object>;
|
|
20
|
-
getConfiguration(): Promise<Object>;
|
|
21
|
-
getUpdateMetadata(updateState: number): Promise<Object>;
|
|
22
|
-
getNewStatusReport(): Promise<Object>;
|
|
23
|
-
installUpdate(updatePackage: Object, installMode: number, minimumBackgroundDuration: number): Promise<void>;
|
|
24
|
-
isFailedUpdate(packageHash: string): Promise<boolean>;
|
|
25
|
-
isFirstRun(packageHash: string): Promise<boolean>;
|
|
26
|
-
notifyApplicationReady(): Promise<void>;
|
|
27
|
-
recordStatusReported(statusReport: Object): void;
|
|
28
|
-
saveStatusReportForRetry(statusReport: Object): void;
|
|
29
|
-
downloadAndReplaceCurrentBundle(remoteBundleUrl: string): void;
|
|
30
|
-
clearUpdates(): void;
|
|
31
|
-
getLatestRollbackInfo(): Promise<Object>;
|
|
32
|
-
setLatestRollbackInfo(packageHash: string): Promise<void>;
|
|
33
|
-
|
|
34
|
-
// Events
|
|
35
|
-
addListener(eventName: string): void;
|
|
36
|
-
removeListeners(count: number): void;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default TurboModuleRegistry.get<Spec>('CodePush');
|