【发布时间】:2016-11-08 15:46:11
【问题描述】:
当收到远程通知时,是否可以在 javascript ( react native ) 中运行函数?唤醒远程通知会在后台做出本机反应吗?
还是应该用 Swift / Objective-C 来完成?
【问题讨论】:
标签: javascript ios push-notification react-native apple-push-notifications
当收到远程通知时,是否可以在 javascript ( react native ) 中运行函数?唤醒远程通知会在后台做出本机反应吗?
还是应该用 Swift / Objective-C 来完成?
【问题讨论】:
标签: javascript ios push-notification react-native apple-push-notifications
绝对有可能!查看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。
【讨论】:
PushNotificationIOS 即使用户杀死了应用程序也能正常工作吗?还是只支持背景/前景?