React native push notifcation在收到的通知上运行函数

时间:2016-11-08 15:46:12

标签: javascript ios push-notification react-native apple-push-notifications

当收到远程通知时,是否可以在javascript中运行一个函数(本机反应)?远程通知是否会在后台响应本机?

或者它应该用Swift / Objective-C完成?

1 个答案:

答案 0 :(得分:1)

绝对可能!查看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