@turbopush/react-native-code-push 9.0.2 → 10.2.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/.gitconfig +6 -0
- package/CodePush.podspec +4 -3
- package/README.md +57 -71
- package/android/app/build.gradle +15 -0
- package/android/app/proguard-rules.pro +8 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +37 -34
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +4 -4
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +202 -45
- package/android/app/src/main/java/com/microsoft/codepush/react/ReactHostHolder.java +11 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +3 -0
- package/android/codepush.gradle +2 -2
- package/docs/api-android.md +24 -55
- package/docs/multi-deployment-testing-android.md +1 -94
- package/docs/setup-android.md +23 -421
- package/docs/setup-ios.md +62 -204
- package/expo.js +324 -0
- package/ios/CodePush/CodePushConfig.m +1 -1
- package/package.json +12 -3
- package/react-native.config.js +2 -1
- package/scripts/tools/linkToolsAndroid.js +1 -1
- package/tsconfig.json +4 -1
- package/windows/CodePush/CodePushConfig.cpp +1 -1
- package/windows-legacy/CodePush.Shared/CodePushConstants.cs +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +0 -37
package/.gitconfig
ADDED
package/CodePush.podspec
CHANGED
|
@@ -9,16 +9,17 @@ Pod::Spec.new do |s|
|
|
|
9
9
|
s.author = package['author']
|
|
10
10
|
s.license = package['license']
|
|
11
11
|
s.homepage = package['homepage']
|
|
12
|
-
s.source = { :git => 'https://github.com/
|
|
12
|
+
s.source = { :git => 'https://github.com/turbopushdev/react-native-code-push.git', :tag => "v#{s.version}"}
|
|
13
13
|
s.ios.deployment_target = '15.5'
|
|
14
14
|
s.tvos.deployment_target = '15.5'
|
|
15
15
|
s.preserve_paths = '*.js'
|
|
16
16
|
s.library = 'z'
|
|
17
17
|
s.source_files = 'ios/CodePush/*.{h,m}'
|
|
18
18
|
s.public_header_files = ['ios/CodePush/CodePush.h']
|
|
19
|
+
s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES" }
|
|
19
20
|
|
|
20
|
-
# Note: Even though there are copy/pasted versions of some of these dependencies in the repo,
|
|
21
|
-
# we explicitly let CocoaPods pull in the versions below so all dependencies are resolved and
|
|
21
|
+
# Note: Even though there are copy/pasted versions of some of these dependencies in the repo,
|
|
22
|
+
# we explicitly let CocoaPods pull in the versions below so all dependencies are resolved and
|
|
22
23
|
# linked properly at a parent workspace level.
|
|
23
24
|
s.dependency 'React-Core'
|
|
24
25
|
s.dependency 'SSZipArchive', '~> 2.5.5'
|
package/README.md
CHANGED
|
@@ -1,47 +1,28 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
Visual Studio App Center was retired on March 31, 2025, except for its Analytics and Diagnostics features. You can learn more about the retirement and the Analytics and Diagnostics extension [here](https://aka.ms/appcenter/retire). CodePush, along with other App Center features, was also retired on March 31, 2025. Consequently, we are archiving this repository.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
[](http://microsoft.github.io/code-push/)
|
|
8
|
-
|
|
9
|
-
#### [Sign up With App Center](https://appcenter.ms/signup?utm_source=CodePush&utm_medium=Azure) to use CodePush
|
|
10
|
-
|
|
11
|
-
## React Native Module for CodePush
|
|
12
|
-
> [!WARNING]
|
|
13
|
-
> React Native CodePush won't support new Architecture. In order to use this plugin on React Native versions starting from 0.76 you will need to [opt out](https://reactnative.dev/blog/2024/10/23/the-new-architecture-is-here#opt-out) from new architecture.
|
|
14
|
-
>
|
|
15
|
-
*Note: This README is only relevant to the latest version of our plugin. If you are using an older version, please switch to the relevant tag on [our GitHub repo](https://github.com/microsoft/react-native-code-push) to view the docs for that particular version.*
|
|
16
|
-
|
|
17
|
-

|
|
1
|
+
# React Native Module for CodePush
|
|
2
|
+
#### [Sign up](https://accounts.turbopush.org/sign-up) to use Turbopush
|
|
18
3
|
|
|
19
4
|
This plugin provides client-side integration for the [CodePush service](https://microsoft.github.io/code-push/), allowing you to easily add a dynamic update experience to your React Native app(s).
|
|
20
5
|
|
|
21
6
|
<!-- React Native Catalog -->
|
|
22
7
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* [Debugging / Troubleshooting](#debugging--troubleshooting)
|
|
42
|
-
* [Example Apps / Starters](#example-apps--starters)
|
|
43
|
-
* [Continuous Integration / Delivery](#continuous-integration--delivery)
|
|
44
|
-
* [TypeScript Consumption](#typescript-consumption)
|
|
8
|
+
- [React Native Module for CodePush](#react-native-module-for-codepush)
|
|
9
|
+
- [Sign up to use Turbopush](#sign-up-to-use-turbopush)
|
|
10
|
+
- [How does it work?](#how-does-it-work)
|
|
11
|
+
- [Supported React Native platforms](#supported-react-native-platforms)
|
|
12
|
+
- [Supported Components](#supported-components)
|
|
13
|
+
- [Getting Started](#getting-started)
|
|
14
|
+
- [Plugin Usage](#plugin-usage)
|
|
15
|
+
- [Store Guideline Compliance](#store-guideline-compliance)
|
|
16
|
+
- [Google play](#google-play)
|
|
17
|
+
- [App Store](#app-store)
|
|
18
|
+
- [Releasing Updates](#releasing-updates)
|
|
19
|
+
- [Multi-Deployment Testing](#multi-deployment-testing)
|
|
20
|
+
- [Dynamic Deployment Assignment](#dynamic-deployment-assignment)
|
|
21
|
+
- [API Reference](#api-reference)
|
|
22
|
+
- [Example Apps / Starters](#example-apps--starters)
|
|
23
|
+
- [Debugging / Troubleshooting](#debugging--troubleshooting)
|
|
24
|
+
- [Continuous Integration / Delivery](#continuous-integration--delivery)
|
|
25
|
+
- [TypeScript Consumption](#typescript-consumption)
|
|
45
26
|
|
|
46
27
|
<!-- React Native Catalog -->
|
|
47
28
|
|
|
@@ -59,36 +40,17 @@ In order to ensure that your end users always have a functioning version of your
|
|
|
59
40
|
|
|
60
41
|
- iOS (7+)
|
|
61
42
|
- Android (4.1+) on TLS 1.2 compatible devices
|
|
62
|
-
- Windows (UWP)
|
|
43
|
+
- Windows (UWP) - Not Tested. We recommend to use [microsoft/code-push-react-native](https://github.com/microsoft/react-native-code-push)
|
|
63
44
|
|
|
64
45
|
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 CodePush plugin in order to support the exact version of React Native you are using. The following table outlines which CodePush plugin versions officially support the respective React Native versions:
|
|
65
46
|
|
|
66
|
-
| React Native version(s) | Supporting CodePush version(s)
|
|
67
|
-
|
|
68
|
-
| <
|
|
69
|
-
| v0.
|
|
70
|
-
| v0.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
| v0.31-v0.33 | v1.14.6-v1.17 *(RN refactored native hosting code)* |
|
|
74
|
-
| v0.34-v0.35 | v1.15-v1.17 *(RN refactored native hosting code)* |
|
|
75
|
-
| v0.36-v0.39 | v1.16-v1.17 *(RN refactored resume handler)* |
|
|
76
|
-
| v0.40-v0.42 | v1.17 *(RN refactored iOS header files)* |
|
|
77
|
-
| v0.43-v0.44 | v2.0+ *(RN refactored uimanager dependencies)* |
|
|
78
|
-
| v0.45 | v3.0+ *(RN refactored instance manager code)* |
|
|
79
|
-
| v0.46 | v4.0+ *(RN refactored js bundle loader code)* |
|
|
80
|
-
| v0.46-v0.53 | v5.1+ *(RN removed unused registration of JS modules)*|
|
|
81
|
-
| v0.54-v0.55 | v5.3+ *(Android Gradle Plugin 3.x integration)* |
|
|
82
|
-
| v0.56-v0.58 | v5.4+ *(RN upgraded versions for Android tools)* |
|
|
83
|
-
| v0.59 | v5.6+ *(RN refactored js bundle loader code)* |
|
|
84
|
-
| v0.60-v0.61 | v6.0+ *(RN migrated to Autolinking)* |
|
|
85
|
-
| v0.62-v0.64 | v6.2+ *(RN removed LiveReload)* |
|
|
86
|
-
| v0.65-v0.70 | v7.0+ *(RN updated iPhone-target-version)* |
|
|
87
|
-
| v0.71 | v8.0+ *(RN moved to react-native-gradle-plugin)* |
|
|
88
|
-
|
|
89
|
-
*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).*
|
|
90
|
-
|
|
91
|
-
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.
|
|
47
|
+
| React Native version(s) | Supporting CodePush version(s) |
|
|
48
|
+
|-------------------------|------------------------------------------------------------------------------------------------------|
|
|
49
|
+
| <v0.76 | **Consider [microsoft/code-push-react-native](https://github.com/microsoft/react-native-code-push)** |
|
|
50
|
+
| v0.76, v0.77, 0.78, 0.79| v10.0+ *(Available for Old/New Architecture)* |
|
|
51
|
+
| v0.80 | v10.1+ *(Available for Old/New Architecture)* |
|
|
52
|
+
|
|
53
|
+
|
|
92
54
|
|
|
93
55
|
### Supported Components
|
|
94
56
|
|
|
@@ -123,7 +85,7 @@ As new core components are released, which support referencing assets, we'll upd
|
|
|
123
85
|
Once you've followed the general-purpose ["getting started"](https://docs.microsoft.com/en-us/appcenter/distribution/codepush/index) instructions for setting up your CodePush account, you can start CodePush-ifying your React Native app by running the following command from within your app's root directory:
|
|
124
86
|
|
|
125
87
|
```shell
|
|
126
|
-
|
|
88
|
+
yarn add @turbopush/react-native-code-push
|
|
127
89
|
```
|
|
128
90
|
|
|
129
91
|
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 CodePush applications for each platform.
|
|
@@ -153,7 +115,7 @@ The simplest way to do this is to "CodePush-ify" your app's root component. To d
|
|
|
153
115
|
* For class component
|
|
154
116
|
|
|
155
117
|
```javascript
|
|
156
|
-
import codePush from "react-native-code-push";
|
|
118
|
+
import codePush from "@turbopush/react-native-code-push";
|
|
157
119
|
|
|
158
120
|
class MyApp extends Component {
|
|
159
121
|
}
|
|
@@ -164,7 +126,7 @@ The simplest way to do this is to "CodePush-ify" your app's root component. To d
|
|
|
164
126
|
* For functional component
|
|
165
127
|
|
|
166
128
|
```javascript
|
|
167
|
-
import codePush from "react-native-code-push";
|
|
129
|
+
import codePush from "@turbopush/react-native-code-push";
|
|
168
130
|
|
|
169
131
|
let MyApp: () => React$Node = () => {
|
|
170
132
|
}
|
|
@@ -179,7 +141,7 @@ The simplest way to do this is to "CodePush-ify" your app's root component. To d
|
|
|
179
141
|
* For class component
|
|
180
142
|
|
|
181
143
|
```javascript
|
|
182
|
-
import codePush from "react-native-code-push";
|
|
144
|
+
import codePush from "@turbopush/react-native-code-push";
|
|
183
145
|
|
|
184
146
|
@codePush
|
|
185
147
|
class MyApp extends Component {
|
|
@@ -189,7 +151,7 @@ The simplest way to do this is to "CodePush-ify" your app's root component. To d
|
|
|
189
151
|
* For functional component
|
|
190
152
|
|
|
191
153
|
```javascript
|
|
192
|
-
import codePush from "react-native-code-push";
|
|
154
|
+
import codePush from "@turbopush/react-native-code-push";
|
|
193
155
|
|
|
194
156
|
const MyApp: () => React$Node = () => {
|
|
195
157
|
}
|
|
@@ -254,6 +216,30 @@ If you would like to display an update confirmation dialog (an "active install")
|
|
|
254
216
|
|
|
255
217
|
*NOTE: If you are using [Redux](http://redux.js.org) and [Redux Saga](https://redux-saga.js.org/), you can alternatively use the [react-native-code-push-saga](http://github.com/lostintangent/react-native-code-push-saga) module, which allows you to customize when `sync` is called in a perhaps simpler/more idiomatic way.*
|
|
256
218
|
|
|
219
|
+
3. For expo user with CNG(Continuous Native Generation)
|
|
220
|
+
```json
|
|
221
|
+
// app.json
|
|
222
|
+
"expo": {
|
|
223
|
+
// ...
|
|
224
|
+
"plugins": [
|
|
225
|
+
[
|
|
226
|
+
"@turbopush/react-native-code-push/expo",
|
|
227
|
+
{
|
|
228
|
+
"ios": {
|
|
229
|
+
"CodePushDeploymentKey": "deployment key",
|
|
230
|
+
"CodePushServerURL": "server url"
|
|
231
|
+
},
|
|
232
|
+
"android": {
|
|
233
|
+
"CodePushDeploymentKey": "deployment key",
|
|
234
|
+
"CodePushServerURL": "server url "
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
|
|
257
243
|
### Store Guideline Compliance
|
|
258
244
|
|
|
259
245
|
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.
|
package/android/app/build.gradle
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
apply plugin: "com.android.library"
|
|
2
2
|
|
|
3
|
+
def isNewArchitectureEnabled() {
|
|
4
|
+
// To opt-in for the New Architecture, you can either:
|
|
5
|
+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
|
|
6
|
+
// - Invoke gradle with `-newArchEnabled=true`
|
|
7
|
+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
|
8
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
def IS_NEW_ARCHITECTURE_ENABLED = isNewArchitectureEnabled()
|
|
12
|
+
|
|
13
|
+
if (IS_NEW_ARCHITECTURE_ENABLED) {
|
|
14
|
+
apply plugin: "com.facebook.react"
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
def DEFAULT_COMPILE_SDK_VERSION = 26
|
|
4
18
|
def DEFAULT_BUILD_TOOLS_VERSION = "26.0.3"
|
|
5
19
|
def DEFAULT_TARGET_SDK_VERSION = 26
|
|
@@ -16,6 +30,7 @@ android {
|
|
|
16
30
|
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
|
|
17
31
|
versionCode 1
|
|
18
32
|
versionName "1.0"
|
|
33
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", IS_NEW_ARCHITECTURE_ENABLED.toString()
|
|
19
34
|
}
|
|
20
35
|
|
|
21
36
|
lintOptions {
|
|
@@ -21,5 +21,13 @@
|
|
|
21
21
|
private final ** mBundleLoader;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
-keepclassmembers class com.facebook.react.runtime.ReactHostImpl {
|
|
25
|
+
private final ** mReactHostDelegate;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
-keep interface com.facebook.react.runtime.ReactHostDelegate { *; }
|
|
29
|
+
|
|
30
|
+
-keep class * implements com.facebook.react.runtime.ReactHostDelegate { *; }
|
|
31
|
+
|
|
24
32
|
# Can't find referenced class org.bouncycastle.**
|
|
25
33
|
-dontwarn com.nimbusds.jose.**
|
|
@@ -5,13 +5,12 @@ import android.content.pm.PackageInfo;
|
|
|
5
5
|
import android.content.pm.PackageManager;
|
|
6
6
|
import android.content.res.Resources;
|
|
7
7
|
|
|
8
|
+
import com.facebook.react.ReactHost;
|
|
8
9
|
import com.facebook.react.ReactInstanceManager;
|
|
9
10
|
import com.facebook.react.ReactPackage;
|
|
10
11
|
import com.facebook.react.bridge.JavaScriptModule;
|
|
11
12
|
import com.facebook.react.bridge.NativeModule;
|
|
12
13
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
13
|
-
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
|
14
|
-
import com.facebook.react.modules.debug.interfaces.DeveloperSettings;
|
|
15
14
|
import com.facebook.react.uimanager.ViewManager;
|
|
16
15
|
|
|
17
16
|
import org.json.JSONException;
|
|
@@ -20,9 +19,20 @@ import org.json.JSONObject;
|
|
|
20
19
|
import java.io.File;
|
|
21
20
|
import java.util.ArrayList;
|
|
22
21
|
import java.util.List;
|
|
23
|
-
import java.lang.reflect.Method;
|
|
24
22
|
|
|
25
23
|
public class CodePush implements ReactPackage {
|
|
24
|
+
private static final Object LOCK = new Object();
|
|
25
|
+
private static volatile CodePush mCurrentInstance;
|
|
26
|
+
public static CodePush getInstance(String deploymentKey, Context context, boolean isDebugMode) {
|
|
27
|
+
if (mCurrentInstance == null) {
|
|
28
|
+
synchronized (LOCK) {
|
|
29
|
+
if (mCurrentInstance == null) {
|
|
30
|
+
mCurrentInstance = new CodePush(deploymentKey, context, isDebugMode);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return mCurrentInstance;
|
|
35
|
+
}
|
|
26
36
|
|
|
27
37
|
private static boolean sIsRunningBinaryVersion = false;
|
|
28
38
|
private static boolean sNeedToReportRollback = false;
|
|
@@ -40,7 +50,7 @@ public class CodePush implements ReactPackage {
|
|
|
40
50
|
|
|
41
51
|
// Config properties.
|
|
42
52
|
private String mDeploymentKey;
|
|
43
|
-
private static String mServerUrl = "https://
|
|
53
|
+
private static String mServerUrl = "https://api.turbopush.org/";
|
|
44
54
|
|
|
45
55
|
private Context mContext;
|
|
46
56
|
private final boolean mIsDebugMode;
|
|
@@ -48,7 +58,8 @@ public class CodePush implements ReactPackage {
|
|
|
48
58
|
private static String mPublicKey;
|
|
49
59
|
|
|
50
60
|
private static ReactInstanceHolder mReactInstanceHolder;
|
|
51
|
-
|
|
61
|
+
|
|
62
|
+
private static ReactHostHolder mReactHostHolder;
|
|
52
63
|
|
|
53
64
|
public CodePush(String deploymentKey, Context context) {
|
|
54
65
|
this(deploymentKey, context, false);
|
|
@@ -58,7 +69,7 @@ public class CodePush implements ReactPackage {
|
|
|
58
69
|
return mServerUrl;
|
|
59
70
|
}
|
|
60
71
|
|
|
61
|
-
|
|
72
|
+
private CodePush(String deploymentKey, Context context, boolean isDebugMode) {
|
|
62
73
|
mContext = context.getApplicationContext();
|
|
63
74
|
|
|
64
75
|
mUpdateManager = new CodePushUpdateManager(context.getFilesDir().getAbsolutePath());
|
|
@@ -84,22 +95,23 @@ public class CodePush implements ReactPackage {
|
|
|
84
95
|
String serverUrlFromStrings = getCustomPropertyFromStringsIfExist("ServerUrl");
|
|
85
96
|
if (serverUrlFromStrings != null) mServerUrl = serverUrlFromStrings;
|
|
86
97
|
|
|
87
|
-
|
|
98
|
+
// ignore liveReload when CodePush is initializing so that unneccessary cache could be cleared
|
|
99
|
+
clearDebugCacheIfNeeded(false);
|
|
88
100
|
initializeUpdateAfterRestart();
|
|
89
101
|
}
|
|
90
102
|
|
|
91
|
-
|
|
103
|
+
private CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl) {
|
|
92
104
|
this(deploymentKey, context, isDebugMode);
|
|
93
105
|
mServerUrl = serverUrl;
|
|
94
106
|
}
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
private CodePush(String deploymentKey, Context context, boolean isDebugMode, int publicKeyResourceDescriptor) {
|
|
97
109
|
this(deploymentKey, context, isDebugMode);
|
|
98
110
|
|
|
99
111
|
mPublicKey = getPublicKeyByResourceDescriptor(publicKeyResourceDescriptor);
|
|
100
112
|
}
|
|
101
113
|
|
|
102
|
-
|
|
114
|
+
private CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl, Integer publicKeyResourceDescriptor) {
|
|
103
115
|
this(deploymentKey, context, isDebugMode);
|
|
104
116
|
|
|
105
117
|
if (publicKeyResourceDescriptor != null) {
|
|
@@ -146,31 +158,10 @@ public class CodePush implements ReactPackage {
|
|
|
146
158
|
return null;
|
|
147
159
|
}
|
|
148
160
|
|
|
149
|
-
|
|
150
|
-
//
|
|
161
|
+
public void clearDebugCacheIfNeeded(boolean isLiveReloadEnabled) {
|
|
162
|
+
// for checking if we use LiveReload mode. In this case we should not remove ReactNativeDevBundle.js file
|
|
151
163
|
// because we get error with trying to get this after reloading. Issue: https://github.com/microsoft/react-native-code-push/issues/1272
|
|
152
|
-
if (
|
|
153
|
-
DevSupportManager devSupportManager = instanceManager.getDevSupportManager();
|
|
154
|
-
if (devSupportManager != null) {
|
|
155
|
-
DeveloperSettings devSettings = devSupportManager.getDevSettings();
|
|
156
|
-
Method[] methods = devSettings.getClass().getMethods();
|
|
157
|
-
for (Method m : methods) {
|
|
158
|
-
if (m.getName().equals("isReloadOnJSChangeEnabled")) {
|
|
159
|
-
try {
|
|
160
|
-
return (boolean) m.invoke(devSettings);
|
|
161
|
-
} catch (Exception x) {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public void clearDebugCacheIfNeeded(ReactInstanceManager instanceManager) {
|
|
173
|
-
if (mIsDebugMode && mSettingsManager.isPendingUpdate(null) && !isLiveReloadEnabled(instanceManager)) {
|
|
164
|
+
if (mIsDebugMode && mSettingsManager.isPendingUpdate(null) && !isLiveReloadEnabled) {
|
|
174
165
|
// This needs to be kept in sync with https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java#L78
|
|
175
166
|
File cachedDevBundle = new File(mContext.getFilesDir(), "ReactNativeDevBundle.js");
|
|
176
167
|
if (cachedDevBundle.exists()) {
|
|
@@ -411,6 +402,10 @@ public class CodePush implements ReactPackage {
|
|
|
411
402
|
mReactInstanceHolder = reactInstanceHolder;
|
|
412
403
|
}
|
|
413
404
|
|
|
405
|
+
public static void setReactHost(ReactHostHolder reactHostHolder) {
|
|
406
|
+
mReactHostHolder = reactHostHolder;
|
|
407
|
+
}
|
|
408
|
+
|
|
414
409
|
static ReactInstanceManager getReactInstanceManager() {
|
|
415
410
|
if (mReactInstanceHolder == null) {
|
|
416
411
|
return null;
|
|
@@ -418,6 +413,14 @@ public class CodePush implements ReactPackage {
|
|
|
418
413
|
return mReactInstanceHolder.getReactInstanceManager();
|
|
419
414
|
}
|
|
420
415
|
|
|
416
|
+
static ReactHost getReactHost() {
|
|
417
|
+
if (mReactHostHolder == null) {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return mReactHostHolder.getReactHost();
|
|
422
|
+
}
|
|
423
|
+
|
|
421
424
|
@Override
|
|
422
425
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
|
|
423
426
|
CodePushNativeModule codePushModule = new CodePushNativeModule(reactApplicationContext, this, mUpdateManager, mTelemetryManager, mSettingsManager);
|
|
@@ -4,13 +4,13 @@ import android.app.Activity;
|
|
|
4
4
|
import android.app.AlertDialog;
|
|
5
5
|
import android.content.DialogInterface;
|
|
6
6
|
|
|
7
|
+
import com.facebook.react.bridge.BaseJavaModule;
|
|
7
8
|
import com.facebook.react.bridge.Callback;
|
|
8
9
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
9
10
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
11
|
import com.facebook.react.bridge.ReactMethod;
|
|
12
12
|
|
|
13
|
-
public class CodePushDialog extends
|
|
13
|
+
public class CodePushDialog extends BaseJavaModule {
|
|
14
14
|
|
|
15
15
|
public CodePushDialog(ReactApplicationContext reactContext) {
|
|
16
16
|
super(reactContext);
|
|
@@ -19,14 +19,14 @@ public class CodePushDialog extends ReactContextBaseJavaModule{
|
|
|
19
19
|
@ReactMethod
|
|
20
20
|
public void showDialog(final String title, final String message, final String button1Text,
|
|
21
21
|
final String button2Text, final Callback successCallback, Callback errorCallback) {
|
|
22
|
-
Activity currentActivity = getCurrentActivity();
|
|
22
|
+
Activity currentActivity = getReactApplicationContext().getCurrentActivity();
|
|
23
23
|
if (currentActivity == null || currentActivity.isFinishing()) {
|
|
24
24
|
// If getCurrentActivity is null, it could be because the app is backgrounded,
|
|
25
25
|
// so we show the dialog when the app resumes)
|
|
26
26
|
getReactApplicationContext().addLifecycleEventListener(new LifecycleEventListener() {
|
|
27
27
|
@Override
|
|
28
28
|
public void onHostResume() {
|
|
29
|
-
Activity currentActivity = getCurrentActivity();
|
|
29
|
+
Activity currentActivity = getReactApplicationContext().getCurrentActivity();
|
|
30
30
|
if (currentActivity != null) {
|
|
31
31
|
getReactApplicationContext().removeLifecycleEventListener(this);
|
|
32
32
|
showDialogInternal(title, message, button1Text, button2Text, successCallback, currentActivity);
|