仅在 android 中反应本机 0.62 自动链接

Bar*_*rak 1 react-native react-native-firebase react-native-push-notification

我正在使用使用自动链接的 react-native 0.62 我想知道是否有一种方法可以自动链接仅适用于 android 或仅适用于 ios。

我真正的问题是我使用 react-native-firebsae 和 react-native-push-notification 来发送本地通知,而我只需要为 android 使用“react-native-push-notification”。

在我添加“react-native-push-notification”并执行 pod install 后,我的 IOS 显示错误“Invarian Violation: Native module cannot be null”。先感谢您

Wah*_*tar 6

可以像这样在单个平台上进行链接。

第一个选项

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

第二种选择

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
      },
    },
  },
};
Run Code Online (Sandbox Code Playgroud)

链接到文档

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