React-native-navigation: Code-push usage with RNNN v2?

Created on 7 Feb 2018  路  4Comments  路  Source: wix/react-native-navigation

Issue Description

I'm using react-native-navigation v2.
What's the recommended/best way to use code-push?

This is how I initialize my app:

Navigation.events().onAppLaunched(() => {
  initializeTracking();
  Navigation.setRoot({
    container: {
      name: ROOT_SCREEN,
    },
  });
});

I was thinking maybe wrapping with code-push function, but then what happens to my other registered screens?

Environment

  • React Native Navigation version: v2
  • React Native version: 0.48.1
  • Platform(s) (iOS, Android, or both?): iOS
looking for contributors v2

Most helpful comment

Update the MainApplication.java file to use CodePush via the following changes:

// ...
import com.facebook.react.ReactInstanceManager;

// Add CodePush imports
import com.microsoft.codepush.react.CodePush;

public class MainApplication extends NavigationApplication {

    @Override
    public boolean isDebug() {
        return BuildConfig.DEBUG;
    }

    @Override
    protected ReactGateway createReactGateway() {
        ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
            @javax.annotation.Nullable
            @Override
            protected String getJSBundleFile() {
                return CodePush.getJSBundleFile();
            }

        };
        return new ReactGateway(this, isDebug(), host);
    }

    @Override
    public List<ReactPackage> createAdditionalReactPackages() {
        return Arrays.<ReactPackage>asList(
        new CodePush("deployment-key-here", getApplicationContext(), isDebug())
        //,MainReactPackage , etc...
    }
}

For more details, please follow the link below:
https://github.com/Microsoft/react-native-code-push/blob/master/docs/setup-android.md#wix-react-native-navigation-applications

credits to @andresesfm

All 4 comments

I'm not using RNNv2, but I think maybe you only need to register code-push in your ROOT_SCREEN ?

You're right. thanks

@emroot i was stuck with this. May i know how did you use / using codepush with RNN V2

Update the MainApplication.java file to use CodePush via the following changes:

// ...
import com.facebook.react.ReactInstanceManager;

// Add CodePush imports
import com.microsoft.codepush.react.CodePush;

public class MainApplication extends NavigationApplication {

    @Override
    public boolean isDebug() {
        return BuildConfig.DEBUG;
    }

    @Override
    protected ReactGateway createReactGateway() {
        ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
            @javax.annotation.Nullable
            @Override
            protected String getJSBundleFile() {
                return CodePush.getJSBundleFile();
            }

        };
        return new ReactGateway(this, isDebug(), host);
    }

    @Override
    public List<ReactPackage> createAdditionalReactPackages() {
        return Arrays.<ReactPackage>asList(
        new CodePush("deployment-key-here", getApplicationContext(), isDebug())
        //,MainReactPackage , etc...
    }
}

For more details, please follow the link below:
https://github.com/Microsoft/react-native-code-push/blob/master/docs/setup-android.md#wix-react-native-navigation-applications

credits to @andresesfm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tmaly1980 picture tmaly1980  路  3Comments

zhanguangao picture zhanguangao  路  3Comments

yayanartha picture yayanartha  路  3Comments

henrikra picture henrikra  路  3Comments

birkir picture birkir  路  3Comments