Search code examples
react-nativereact-native-firebasereact-native-push-notification

React native 0.62 autolinking just in android


I'm use react-native 0.62 that use autolinking i would like to know if there is a way to auto linking just for android or just for ios.

My real problem is that i use react-native-firebsae with react-native-push-notification for sending local notification, and i need 'react-native-push-notification' just for android.

After i yarn add 'react-native-push-notification' and do pod install my IOS show the error "Invarian Violation: Native module cannot be null". Thank you in advance


Solution

  • Linking on a single platform can be done like this.

    First Option

    react-native link your-library-js-package-name --platform (android or ios)

    Second Option

    Create a react-native.config.js file in the root of your project.

    module.exports = {
      dependencies: {
        'some-unsupported-package': {
          platforms: {
            android: null, // disable Android platform, other platforms will still autolink if provided
          },
        },
      },
    };
    

    Link to docs

    https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#how-can-i-customize-how-autolinking-works-for-my-package