@appzung/react-native-code-push 11.0.2 → 11.0.3

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/README.md CHANGED
@@ -112,7 +112,7 @@ We try our best to maintain backwards compatibility of our plugin with previous
112
112
  | v0.71-v0.79 | 4.1+ (TLS 1.2+) | 9 | ✅ | ❌ | v8.3.2 |
113
113
  | v0.71-v0.79 | 4.1+ (TLS 1.2+) | 15.5 | ✅ | ❌ | v9.0.2 |
114
114
  | v0.71-v0.80 | 4.1+ (TLS 1.2+) | 15.5 | ✅ | ❌ | v10+ |
115
- | v0.74-v0.81 | 4.1+ (TLS 1.2+) | 15.5 | ✅ | ✅ | v11+ |
115
+ | v0.74-v0.84 | 4.1+ (TLS 1.2+) | 15.5 | ✅ | ✅ | v11+ |
116
116
 
117
117
  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.
118
118
 
@@ -140,10 +140,28 @@ By default, and this is recommended for production environments, CodePush will c
140
140
  If you would like your app to discover updates more quickly, you can also choose to sync up with the CodePush server every time the app resumes from the background.
141
141
 
142
142
  ```javascript
143
- withCodePush({ checkFrequency: CheckFrequency.ON_APP_RESUME })(MyApp);
143
+ import withCodePush, { CheckFrequency, InstallMode } from '@appzung/react-native-code-push';
144
+
145
+ withCodePush({
146
+ checkFrequency: CheckFrequency.ON_APP_RESUME,
147
+ })(MyApp);
148
+ ```
149
+
150
+ For a more aggressive setup, you may choose to also install updates in the background or when the app resumes. Note that because the app would reload during update installation, the user might be slightly bothered unless you have a mechanism to come back to the exact same app state after restarting. You may minimize this discomfort using `minimumBackgroundDuration`.
151
+ On Android in New Arch it is preferable to use ON_NEXT_RESUME instead of ON_NEXT_SUSPEND because it looks like React Native has a bug where network requests fail when React initializes in the background.
152
+
153
+ ```javascript
154
+ import withCodePush, { CheckFrequency, InstallMode } from '@appzung/react-native-code-push';
155
+ import { Platform } from 'react-native';
156
+
157
+ withCodePush({
158
+ checkFrequency: CheckFrequency.ON_APP_RESUME,
159
+ installMode: Platform.OS === 'android' ? InstallMode.ON_NEXT_RESUME : InstallMode.ON_NEXT_SUSPEND,
160
+ minimumBackgroundDuration: 60 * 5, // if the app is suspended more than 5 minutes, install the update. If the app is restarted (killed and restarted) it will also install the update.
161
+ })(MyApp);
144
162
  ```
145
163
 
146
- Alternatively, if you want fine-grained control over when the check happens (like a button press or timer interval), eg. in a staging environment, you can call [`CodePush.sync()`](docs/api-js/functions/sync.md) at any time with your desired `SyncOptions`, and turn off CodePush's automatic checking by specifying a manual `checkFrequency`:
164
+ Alternatively, if you want fine-grained control over when the check happens (like a button press or timer interval), e.g. in a staging environment, you can call [`CodePush.sync()`](docs/api-js/functions/sync.md) at any time with your desired `SyncOptions`, and turn off CodePush's automatic checking by specifying a manual `checkFrequency`:
147
165
 
148
166
  ```javascript
149
167
  import withCodePush, { CheckFrequency, InstallMode, sync } from '@appzung/react-native-code-push';
@@ -285,3 +303,4 @@ Now you'll be able to see CodePush logs in either debug or release mode, on both
285
303
  | I've released an update for iOS but my Android app also shows an update and it breaks it | Be sure you have different release channels for each platform in order to receive updates correctly |
286
304
  | I've released new update but changes are not reflected | Be sure that you are running app in modes other than Debug. In Debug mode, React Native app always downloads JS bundle generated by packager, so JS bundle downloaded by CodePush does not apply. |
287
305
  | Android compilation fails after migrating to AppZung with error "Task :app:checkReleaseAarMetadata FAILED A problem was found with the configuration of task ':app:checkReleaseAarMetadata' (type 'CheckAarMetadataTask')". | In `android/settings.gradle` remove the lines about CodePush. Be sure to read the other [migration steps](./docs/migrating-to-v10.md) carefully to review if you missed any others. |
306
+ | `appzung releases deploy-react-native` fails with "SyntaxError: missing ) after argument list" in pnpm workspaces | Use `--react-native-cli-path` flag to specify the path to the RN CLI JS file: `--react-native-cli-path=./node_modules/react-native/cli.js` |
@@ -19,6 +19,7 @@
19
19
  # Invoked via reflection, when setting js bundle.
20
20
  -keepclassmembers class com.facebook.react.ReactInstanceManager {
21
21
  private final ** mBundleLoader;
22
+ private ** mAttachedReactRoots;
22
23
  }
23
24
  -keepclassmembers class com.facebook.react.runtime.ReactHostImpl {
24
25
  private final ** mReactHostDelegate;
@@ -27,5 +28,13 @@
27
28
  -keep interface com.facebook.react.runtime.ReactHostDelegate { *; }
28
29
  -keep class * implements com.facebook.react.runtime.ReactHostDelegate { *; }
29
30
 
31
+ # Invoked via reflection, when resetting root views.
32
+ -keepclassmembers interface com.facebook.react.ReactRoot {
33
+ public ** getRootViewGroup();
34
+ }
35
+ -keepclassmembers class * implements com.facebook.react.ReactRoot {
36
+ public ** getRootViewGroup();
37
+ }
38
+
30
39
  # Can't find referenced class org.bouncycastle.**
31
40
  -dontwarn com.nimbusds.jose.**
@@ -7,6 +7,7 @@ import android.os.Handler;
7
7
  import android.os.Looper;
8
8
  import android.view.Choreographer;
9
9
  import android.view.View;
10
+ import android.view.ViewGroup;
10
11
 
11
12
  import androidx.annotation.OptIn;
12
13
 
@@ -268,6 +269,7 @@ public class CodePushNativeModule extends BaseJavaModule {
268
269
  @Override
269
270
  public void run() {
270
271
  try {
272
+ resetReactRootViews(instanceManager);
271
273
  instanceManager.recreateReactContextInBackground();
272
274
  mCodePush.initializeUpdateAfterRestart();
273
275
  } catch (Exception e) {
@@ -315,6 +317,26 @@ public class CodePushNativeModule extends BaseJavaModule {
315
317
  }
316
318
  }
317
319
 
320
+ private void resetReactRootViews(ReactInstanceManager instanceManager) throws NoSuchFieldException, IllegalAccessException {
321
+ Field mAttachedReactRootsField = instanceManager.getClass().getDeclaredField("mAttachedReactRoots");
322
+ mAttachedReactRootsField.setAccessible(true);
323
+ java.util.Set<?> mAttachedReactRoots = (java.util.Set<?>) mAttachedReactRootsField.get(instanceManager);
324
+ if (mAttachedReactRoots != null) {
325
+ for (Object reactRoot : mAttachedReactRoots) {
326
+ try {
327
+ Method getRootViewGroupMethod = reactRoot.getClass().getMethod("getRootViewGroup");
328
+ ViewGroup rootViewGroup = (ViewGroup) getRootViewGroupMethod.invoke(reactRoot);
329
+ if (rootViewGroup != null) {
330
+ rootViewGroup.removeAllViews();
331
+ rootViewGroup.setId(View.NO_ID);
332
+ }
333
+ } catch (Exception e) {
334
+ CodePushUtils.log("Failed to reset root view: " + e.getMessage());
335
+ }
336
+ }
337
+ }
338
+ }
339
+
318
340
  // Use reflection to find the ReactInstanceManager. See #556 for a proposal for a less brittle way to approach this.
319
341
  private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException {
320
342
  ReactInstanceManager instanceManager = CodePush.getReactInstanceManager();
@@ -686,7 +708,12 @@ public class CodePushNativeModule extends BaseJavaModule {
686
708
  if (installMode == CodePushInstallMode.IMMEDIATE.getValue()
687
709
  || durationInBackground >= CodePushNativeModule.this.mMinimumBackgroundDuration) {
688
710
  CodePushUtils.log("Loading bundle on resume");
689
- restartAppInternal(false);
711
+ new Handler(Looper.getMainLooper()).post(new Runnable() {
712
+ @Override
713
+ public void run() {
714
+ restartAppInternal(false);
715
+ }
716
+ });
690
717
  }
691
718
  }
692
719
  }
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // Generated by genversion.
8
- const version = exports.version = '11.0.2';
8
+ const version = exports.version = '11.0.3';
9
9
  //# sourceMappingURL=version.js.map
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
 
3
3
  // Generated by genversion.
4
- export const version = '11.0.2';
4
+ export const version = '11.0.3';
5
5
  //# sourceMappingURL=version.js.map
@@ -1,2 +1,2 @@
1
- export declare const version = "11.0.2";
1
+ export declare const version = "11.0.3";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const version = "11.0.2";
1
+ export declare const version = "11.0.3";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appzung/react-native-code-push",
3
- "version": "11.0.2",
3
+ "version": "11.0.3",
4
4
  "description": "React Native plugin for the CodePush service",
5
5
  "author": "Louis Lagrange <lagrange.louis@gmail.com> (https://github.com/Minishlink)",
6
6
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "repository": {
50
50
  "type": "git",
51
- "url": "https://github.com/appzung/react-native-code-push"
51
+ "url": "git+https://github.com/appzung/react-native-code-push.git"
52
52
  },
53
53
  "dependencies": {
54
54
  "hoist-non-react-statics": "^3.3.2"
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '11.0.2';
2
+ export const version = '11.0.3';