你什么时候使用 react-native-push-notification vs @react-native-community/push-notification-ios?

When do you use react-native-push-notification vs @react-native-community/push-notification-ios?

我正在阅读 react-native-push-notification and it indicates that for iOS, you use @react-native-community/push-notification-ios. It seems as though you have to add both of these modules separately. However, I don't understand which to use in my actual code. Do you use var PushNotification = require("react-native-push-notification"); as it says in react-native-push-notification, or do you use import PushNotificationIOS from "@react-native-community/push-notification-ios"; from @react-native-community/push-notification-ios 的安装说明?

您的 package.json 中必须同时包含这两个包,但您不需要将 PushNotificationIOS 用于完成处理程序 as shown in the usage section here 以外的任何其他内容 as shown in the usage section here

不过,一般来说,您只需要使用 var PushNotification = require("react-native-push-notification") 并调用您的处理程序。