简体   繁体   English

react-native-push-notification 在 ios 设备上不起作用

[英]react-native-push-notification doesn't work on ios DEVICE

I'm using react-native-push-notification , but I have a problem.我正在使用react-native-push-notification ,但我遇到了问题。
With IOS simulator or android emulator , Everything works well.使用IOS simulatorandroid emulator ,一切正常。
But with real iphone device , push notification doesn't work.但是对于real iphone device ,推送通知不起作用。 (on release mode or on debug mode, both are not worked. (在发布模式或调试模式下,两者都不起作用。

Here is my setting.这是我的设置。

Link binary with Libraries将二进制文件与库链接

Set Search Header Path设置搜索标题路径

I check Capabilities / Background Modes / Remote notification on XCODE我在 XCODE 上检查Capabilities / Background Modes / Remote notification

And PushNotification.configure和 PushNotification.configure

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 />;
    }
}

And when I have to push notification当我必须推送通知时

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

As I said before, notification works well on all simulator (Xcode IOS, android).正如我之前所说,通知适用于所有simulator (Xcode IOS、android)。
But I don't know why notification doesn't work on real IOS device .但我不知道为什么通知在real IOS device上不起作用。

If you want more environment or settings on my project, please comment.如果您想在我的项目中获得更多环境或设置,请发表评论。

Update -更新 -

I didn't register on Apple Developer Program .我没有注册Apple Developer Program
Is that reason why I can't use notification on real IOS device?这就是我不能在真正的 IOS 设备上使用通知的原因吗?

Yes, I think push notification is not work in iOS simulator so you need to check this in real a device and also check the certificate for push notification is proper while making a release build.是的,我认为推送通知在 iOS 模拟器中不起作用,因此您需要在真实设备中进行检查,并在发布版本时检查推送通知的证书是否正确。

Please also check you get proper device token on onRegister function还请检查您是否在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,
        });

Plese make sure In settings push notification is enabled for your app请确保在设置中为您的应用启用推送通知

由于Xcode 11.4 - IOS Simulator 也应该支持推送通知

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我使用带有 xcode 的真实 ios 设备进行测试时,react-native-push-notification 远程不显示 - react-native-push-notification remote doesn't show when I test with real ios device with xcode 如何在ios上的react-native-push-notification中向通知对象添加其他数据? - How to add additional data to a notification object in react-native-push-notification on ios? 使用 react-native-push-notification 删除以前的通知 - Delete previous notification(s) using react-native-push-notification iOS-推送通知证书无效 - IOS - Push Notification Certificate Doesn't Work iOS推送通知声音不起作用 - IOS push Notification sound doesn't work 反应原生 ios willPresentNotification function 不处理前台的推送通知 - react native ios willPresentNotification function doesn't handle push notification in the foreground React-native:使用 zo0r/react-native-push-notification 显示前台通知,如后台通知 - React-native: display foreground notifications like background notifications with zo0r/react-native-push-notification 推送通知声音在iOS8上不起作用 - Push notification sound doesn't work on iOS8 unregisterForRemoteNotifications不适用于iOS8-推送通知 - unregisterForRemoteNotifications doesn't work for iOS8 - Push Notification 在后台模式下,无声推送通知在iOS7上不起作用 - Silent push notification doesn't work on iOS7 in background mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM