Created
August 2, 2020 03:36
-
-
Save naishe/1075527924b06b7a57c99b6726f8898b to your computer and use it in GitHub Desktop.
Integrating CodePush 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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