bec*_*cky 5 push-notification ios react-native
我是本机反应的新手,我正在尝试通过 iOS 设置推送通知。
我已经安装了 pushNotificationios 并按照给出的说明进行了操作。我也注册为 Apple 开发人员。
当我运行我的应用程序时,推送通知似乎不起作用。当我进入我的 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,
};Run Code Online (Sandbox Code Playgroud)
我发现你的包裹在权限方面存在一些问题
\n\n您可以使用react-native-permissions包来获取通知权限
\n\nimport {requestNotifications} from \'react-native-permissions\';\n\nrequestNotifications([\'alert\', \'sound\']).then(({status, settings}) => {\n // \xe2\x80\xa6\n});\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
3933 次 |
| 最近记录: |