diff --git a/Examples/CodePushDemoApp/.flowconfig b/Examples/CodePushDemoApp/.flowconfig index e28e2f5..4bea710 100644 --- a/Examples/CodePushDemoApp/.flowconfig +++ b/Examples/CodePushDemoApp/.flowconfig @@ -1,7 +1,7 @@ [ignore] # We fork some components by platform. -.*/*.android.js +.*/*[.]android.js # Ignore templates with `@flow` in header .*/local-cli/generator.* @@ -9,6 +9,21 @@ # Ignore malformed json .*/node_modules/y18n/test/.*\.json +# Ignore the website subdir +/website/.* + +# Ignore BUCK generated dirs +/\.buckd/ + +# Ignore unexpected extra @providesModule +.*/node_modules/commoner/test/source/widget/share.js + +# Ignore duplicate module providers +# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root +.*/Libraries/react-native/React.js +.*/Libraries/react-native/ReactNative.js +.*/node_modules/jest-runtime/build/__tests__/.* + [include] [libs] @@ -33,9 +48,11 @@ suppress_type=$FlowIssue suppress_type=$FlowFixMe suppress_type=$FixMe -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(30\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(30\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy +unsafe.enable_getters_and_setters=true + [version] -^0.27.0 +^0.30.0 diff --git a/Examples/CodePushDemoApp/iOS/CodePushDemoApp/AppDelegate.m b/Examples/CodePushDemoApp/iOS/CodePushDemoApp/AppDelegate.m index 3c8b32b..343c42c 100644 --- a/Examples/CodePushDemoApp/iOS/CodePushDemoApp/AppDelegate.m +++ b/Examples/CodePushDemoApp/iOS/CodePushDemoApp/AppDelegate.m @@ -11,7 +11,7 @@ // 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. //jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; - + // Use CodePush to resolve your JS bundle location, so that your app will run the version of the code distributed via CodePush jsCodeLocation = [CodePush bundleURL]; diff --git a/Examples/CodePushDemoApp/package.json b/Examples/CodePushDemoApp/package.json index db750b6..2d89170 100644 --- a/Examples/CodePushDemoApp/package.json +++ b/Examples/CodePushDemoApp/package.json @@ -7,8 +7,8 @@ }, "dependencies": { "babel-preset-react-native-stage-0": "1.0.1", - "react": "15.2.1", - "react-native": "0.30.0", + "react": "15.3.1", + "react-native": "0.32.0", "react-native-code-push": "file:../../" } } diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index 8839257..dd92902 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -20,3 +20,7 @@ -keepclassmembers class com.facebook.react.ReactInstanceManagerImpl { void recreateReactContextInBackground(); } + +-keepclassmembers class com.facebook.react.XReactInstanceManagerImpl { + void recreateReactContextInBackground(); +} \ No newline at end of file diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java index da9356f..0f1d83b 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java @@ -9,6 +9,7 @@ import android.view.Choreographer; import com.facebook.react.ReactActivity; import com.facebook.react.ReactInstanceManager; import com.facebook.react.bridge.Arguments; +import com.facebook.react.bridge.JSBundleLoader; import com.facebook.react.bridge.LifecycleEventListener; import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; @@ -137,9 +138,20 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule { String latestJSBundleFile = mCodePush.getJSBundleFileInternal(mCodePush.getAssetsBundleFileName()); // #2) Update the locally stored JS bundle file path - Field jsBundleField = instanceManager.getClass().getDeclaredField("mJSBundleFile"); - jsBundleField.setAccessible(true); - jsBundleField.set(instanceManager, latestJSBundleFile); + try { + // RN >= v0.30 + Field bundleLoaderField = instanceManager.getClass().getDeclaredField("mBundleLoader"); + Class jsBundleLoaderClass = Class.forName("com.facebook.react.cxxbridge.JSBundleLoader"); + Method createFileLoaderMethod = jsBundleLoaderClass.getDeclaredMethod("createFileLoader", Context.class, String.class); + Object latestJSBundleLoader = createFileLoaderMethod.invoke(jsBundleLoaderClass, getReactApplicationContext(), latestJSBundleFile); + bundleLoaderField.setAccessible(true); + bundleLoaderField.set(instanceManager, latestJSBundleLoader); + } catch (Exception e) { + // RN <= v0.30 + Field jsBundleField = instanceManager.getClass().getDeclaredField("mJSBundleFile"); + jsBundleField.setAccessible(true); + jsBundleField.set(instanceManager, latestJSBundleFile); + } // #3) Get the context creation method and fire it on the UI thread (which RN enforces) final Method recreateMethod = instanceManager.getClass().getMethod("recreateReactContextInBackground");