react-native-push-notification对ios DEVICE不起作用

时间:2017-08-28 08:16:20

标签: ios react-native notifications device simulator

我正在使用IOS simulator,但我遇到了问题 使用android emulatorreal iphone device,一切运作良好 但是对于Capabilities,推送通知不起作用。 (在发布模式或调试模式下,两者都不起作用。

这是我的设置。

Link binary with Libraries

Set Search Header Path

我在XCODE上查看Background Modes / Remote notification / import React from 'react'; import PushNotification from 'react-native-push-notification'; import { Auth } from '../config/router'; import './ReactotronConfig'; export default class App extends React.Component { constructor(props) { super(props); this.PushConfigure(); } PushConfigure() { PushNotification.configure({ onNotification: (notification) => { console.log('NOTIFICATION:', JSON.stringify(notification)); }, permissions: { alert: true, badge: true, sound: true, }, popInitialNotification: true, requestPermissions: true, }); } render() { return <Auth />; } }

和PushNotification.configure

    const date = new Date(Date.now());
    PushNotification.localNotificationSchedule({
        title: '메세지가 도착 했습니다.',
        message: `${data.user._id}: ${data.text}`,
        date,
        actions: 'Yes',
    });

当我必须推送通知时

simulator

正如我之前所说,通知适用于所有real IOS device(Xcode IOS,android) 但我不知道为什么通知不适用于Apple Developer Program

如果您想在我的项目中使用更多环境或设置,请发表评论。

更新 -

我没有在forEach上注册 这就是为什么我不能在真正的IOS设备上使用通知的原因吗?

2 个答案:

答案 0 :(得分:1)

Xcode 11.4起-iOS模拟器也应支持推送通知

答案 1 :(得分:0)

是的,我认为推送通知在iOS模拟器中不起作用,因此您需要在实际设备中进行检查,并在制作发布版本时检查推送通知的证书是否合适。

还请检查您是否在onRegister功能

上获得了正确的设备令牌
PushNotification.configure({
           onRegister: function (token) {
                console.log((token);
            },
            onNotification: (notification) => {
                console.log('NOTIFICATION:', JSON.stringify(notification));
            },
            permissions: {
                alert: true,
                badge: true,
                sound: true,
            },
            popInitialNotification: true,
            requestPermissions: true,
        });

请确保为您的应用启用了“设置推送通知”