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

Commit c11560f

Browse files
committed
fix 0.32 compat
1 parent cfbdb9f commit c11560f

File tree

5 files changed

+44
-10
lines changed

5 files changed

+44
-10
lines changed

Examples/CodePushDemoApp/.flowconfig

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
[ignore]
22

33
# We fork some components by platform.
4-
.*/*.android.js
4+
.*/*[.]android.js
55

66
# Ignore templates with `@flow` in header
77
.*/local-cli/generator.*
88

99
# Ignore malformed json
1010
.*/node_modules/y18n/test/.*\.json
1111

12+
# Ignore the website subdir
13+
<PROJECT_ROOT>/website/.*
14+
15+
# Ignore BUCK generated dirs
16+
<PROJECT_ROOT>/\.buckd/
17+
18+
# Ignore unexpected extra @providesModule
19+
.*/node_modules/commoner/test/source/widget/share.js
20+
21+
# Ignore duplicate module providers
22+
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
23+
.*/Libraries/react-native/React.js
24+
.*/Libraries/react-native/ReactNative.js
25+
.*/node_modules/jest-runtime/build/__tests__/.*
26+
1227
[include]
1328

1429
[libs]
@@ -33,9 +48,11 @@ suppress_type=$FlowIssue
3348
suppress_type=$FlowFixMe
3449
suppress_type=$FixMe
3550

36-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
37-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
51+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(30\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(30\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
3853
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
3954

55+
unsafe.enable_getters_and_setters=true
56+
4057
[version]
41-
^0.27.0
58+
^0.30.0

Examples/CodePushDemoApp/iOS/CodePushDemoApp/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
1111

1212
// Use React Native's RCTBundleURLProvider to resolve your JS bundle location, so that your app will load the JS bundle from the packager server during development.
1313
//jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
14-
14+
1515
// Use CodePush to resolve your JS bundle location, so that your app will run the version of the code distributed via CodePush
1616
jsCodeLocation = [CodePush bundleURL];
1717

Examples/CodePushDemoApp/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
},
88
"dependencies": {
99
"babel-preset-react-native-stage-0": "1.0.1",
10-
"react": "15.2.1",
11-
"react-native": "0.30.0",
10+
"react": "^15.3.1",
11+
"react-native": "^0.32.0",
1212
"react-native-code-push": "file:../../"
1313
}
1414
}

android/app/proguard-rules.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@
2020
-keepclassmembers class com.facebook.react.ReactInstanceManagerImpl {
2121
void recreateReactContextInBackground();
2222
}
23+
24+
-keepclassmembers class com.facebook.react.XReactInstanceManagerImpl {
25+
void recreateReactContextInBackground();
26+
}

android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.facebook.react.ReactActivity;
1010
import com.facebook.react.ReactInstanceManager;
1111
import com.facebook.react.bridge.Arguments;
12+
import com.facebook.react.bridge.JSBundleLoader;
1213
import com.facebook.react.bridge.LifecycleEventListener;
1314
import com.facebook.react.bridge.Promise;
1415
import com.facebook.react.bridge.ReactApplicationContext;
@@ -137,9 +138,21 @@ private void loadBundle() {
137138
String latestJSBundleFile = mCodePush.getJSBundleFileInternal(mCodePush.getAssetsBundleFileName());
138139

139140
// #2) Update the locally stored JS bundle file path
140-
Field jsBundleField = instanceManager.getClass().getDeclaredField("mJSBundleFile");
141-
jsBundleField.setAccessible(true);
142-
jsBundleField.set(instanceManager, latestJSBundleFile);
141+
try {
142+
// RN >= v0.30
143+
Field bundleLoaderField = instanceManager.getClass().getDeclaredField("mBundleLoader");
144+
Class<?> jsBundleLoaderClass = Class.forName("com.facebook.react.cxxbridge.JSBundleLoader");
145+
Method createFileLoaderMethod = jsBundleLoaderClass.getDeclaredMethod("createFileLoader", Context.class, String.class);
146+
Object latestJSBundleLoader = createFileLoaderMethod.invoke(jsBundleLoaderClass, getReactApplicationContext(), latestJSBundleFile);
147+
bundleLoaderField.setAccessible(true);
148+
bundleLoaderField.set(instanceManager, latestJSBundleLoader);
149+
} catch (Exception e) {
150+
e.printStackTrace();
151+
// RN <= v0.30
152+
Field jsBundleField = instanceManager.getClass().getDeclaredField("mJSBundleFile");
153+
jsBundleField.setAccessible(true);
154+
jsBundleField.set(instanceManager, latestJSBundleFile);
155+
}
143156

144157
// #3) Get the context creation method and fire it on the UI thread (which RN enforces)
145158
final Method recreateMethod = instanceManager.getClass().getMethod("recreateReactContextInBackground");

0 commit comments

Comments
 (0)