【发布时间】:2018-02-05 11:02:06
【问题描述】:
我正在使用react-native-push-notification,但我遇到了问题。
使用IOS simulator 或android emulator,一切正常。
但是对于real iphone device,推送通知不起作用。 (在发布模式或调试模式下,两者都不起作用。
这是我的设置。
我在 XCODE 上查看Capabilities/Background Modes/Remote notification
和 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 />;
}
}
当我必须推送通知时
const date = new Date(Date.now());
PushNotification.localNotificationSchedule({
title: '메세지가 도착 했습니다.',
message: `${data.user._id}: ${data.text}`,
date,
actions: 'Yes',
});
正如我之前所说,通知适用于所有 simulator(Xcode IOS、android)。
但我不知道为什么通知在real IOS device 上不起作用。
如果您想对我的项目有更多的环境或设置,请发表评论。
更新 -
我没有在Apple Developer Program注册。
这就是我无法在真实 IOS 设备上使用通知的原因吗?
【问题讨论】:
-
应用在真机上首次运行时是否要求通知权限?
-
请检查应用询问通知权限并检查推送通知证书是否完善
-
@DinithMinura 是的。权限弹出发生。
-
@NisargThakkar 我在 XCODE 的 CAPABILITIES 中检查了远程通知,第一次运行应用程序时,出现了权限弹出窗口。还有什么要检查的吗?
-
我没有注册 Apple Developer Program。这就是我不能在真正的 IOS 设备上使用通知的原因吗?
标签: ios react-native notifications device simulator