Skip to content

Instantly share code, notes, and snippets.

@naishe
Created August 2, 2020 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naishe/1075527924b06b7a57c99b6726f8898b to your computer and use it in GitHub Desktop.
Save naishe/1075527924b06b7a57c99b6726f8898b to your computer and use it in GitHub Desktop.
Integrating CodePush 3
// File: android/app/src/main/java/com/myapp/MainApplication.java
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
+ import com.microsoft.codepush.react.CodePush; // 1. CodePush
public class MainApplication extends MultiDexApplication implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
+
+ // 2. CODEPUSH: Override the getJSBundleFile method in order to let
+ // the CodePush runtime determine where to get the JS
+ // bundle location from on each app start
+ @Override
+ protected String getJSBundleFile() {
+ return CodePush.getJSBundleFile();
+ }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment