javascript - react native 推送通知以在收到通知时运行功能

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

当收到远程通知时,是否可以在 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/

相关文章:

javascript - 在浏览器中光标的当前位置插入文本

javascript - 如何使用 PhantomJS 保存 AJAX 请求的内容

javascript - 为什么 IE 9 中图像不通过 CSS 参数旋转?

ios - 如何在用户收到推送通知时播放自定义声音文件?

c# - GCM 给出错误 : (401) Unauthorized

javascript - 将 Js 中创建的单选按钮显示为列表项(垂直列表)

ios - 如何通过单击更改 Collection View 单元格中的标签颜色

iphone - 对齐 UILabel 以 UIView 为中心

android - 如何同时使用 GCM 和 Urban Airship 进行 Android 推送通知

asp.net - 为高消息流量 Web 应用程序横向扩展 SignalR 而不使用 Redis