当收到远程通知时,是否可以在 javascript 中运行一个函数(react native)?唤醒远程通知会在后台做出原生 react 吗?
还是应该用 Swift/Objective-C 来完成?
最佳答案
绝对有可能!查看documentation for PushNotificationIOS
componentWillMount() {
PushNotificationIOS.addEventListener('notification', this._onRemoteNotification);
}
_onRemoteNotification(notification) {
// handle the notification
}
您需要 manually link the Library并在您的 AppDelegate.m
文件中添加监听器。
这也假设您已经 configured your APNs with Apple .
关于javascript - react native 推送通知以在收到通知时运行功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40491016/