【发布时间】:2020-05-22 15:55:05
【问题描述】:
我是原生反应新手,我正在尝试通过 iOS 设置推送通知。
我已安装 pushNotificationios 并按照给出的说明进行操作。我还注册了 Apple Developer。
当我运行我的应用程序时,推送通知似乎不起作用。当我进入我的 iPhone 设置并点击应用时,它不会显示通知。
这是我的代码
import PushNotificationIOS from '@react-native-community/push-notification-ios';
import PushNotification from "react-native-push-notification";
const configure = () => {
PushNotification.configure({
onRegister: (token) => {
console.log('TOKEN:', token);
//process token
},
onNotification: (notification) => {
// process the notification
console.log("NOTIFICATION:", notification);
// required on iOS only
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
permissions: {
alert: true,
badge: true,
sound: true
},
popInitialNotification: true,
requestPermissions: true,
});
};
export {
configure,
};
【问题讨论】:
-
这是在模拟器上还是在实际设备上
-
我都试过了
-
您是否添加了“推送通知”功能(xcode->target->签名和功能)?
-
您在 iphone 上收到任何权限框了吗?
-
你在任何文件中调用configure()函数吗?
标签: ios react-native push-notification