Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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