-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question][Android] switch bundle depends on build environment #2039
Comments
Since there is no response, I've run into the source code and found out that we surely need to implement the "if statement" to determine whether it should get the bundle file from CodePush or from the default path on Android. However, I've implemented it differently from the document, here's what I did: iOS - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#define hasCodePushKey ([[ReactNativeConfig envFor:@"CODE_PUSH_KEY"] length]!=0)
if(hasCodePushKey){
return [CodePush bundleURL];
}else{
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
}
} Android @Override
protected String getJSBundleFile() {
boolean hasCodePushKey = !BuildConfig.CODE_PUSH_KEY.isEmpty();
if(hasCodePushKey){
return CodePush.getJSBundleFile();
}else{
// react-native will get bundle from 'index.android.bundle' if getJSBundleFile returns null
return null;
}
} Enable it by the environment variable is more convenient for us to integrate with CI/CD, hope this helps anyone who is also confusing about it. |
@rnike I think you should keep this issue open so an official response can be made and maybe the docs updated. Also faced the same problem today. |
@rdsedmundo Sure, I'll keep it open |
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment. |
This issue will now be closed because it hasn't had any activity for 15 days after stale. Please feel free to open a new issue if you still have a question/issue or suggestion. |
Hi, we are starting to use react-native-code-push in our project(Android/iOS), I'm confused about the difference between changing the bundle URL on the Android and iOS platform.
In the iOS part, the document
recommend using the DEBUG pre-processor macro to dynamically switch between using the packager server and CodePush
But in the android part, this is not mentioned, and the implementation is as below
If we want Android to behave as same as iOS
"only get bundle from codepush if isn't debug"
, should we need to implement it by ourselves like something below?Or this is handled by
CodePush.getJSBundleFile
already?Environment
The text was updated successfully, but these errors were encountered: