react-native-push-notification在ios DEVICE上不起作用
我使用react-native-push-notification
,但是我遇到了问题。
With IOS simulator
or android emulator
,Everything Everything well。
但与real iphone device
,推送通知不起作用。 (在释放模式或调试模式,两者都没有奏效。react-native-push-notification在ios DEVICE上不起作用
这里是我的设置。
我检查Capabilities
/Background Modes
/Remote notification
上XCODE
和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设备上使用通知的原因吗?
是的,我认为推送通知不适用于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,
});
普莱舍确保在设置推送通知你的应用程序启用
有什么办法可以在本地弹出通知,而无需连接任何服务器,如firebase,APN ..? –
是的,有一种方法,请点击链接。这将帮助你本地通知https://github.com/zo0r/react-native-push-notification和https://medium.com/differential/how-to-setup-push-notifications-in-react-native -ios-android-30ea0131355e –
我首先关注了他们,但通知在真实的IOS设备上不起作用。 –
没有应用要求对真正的第一次运行通知权限设备? –
请检查应用程序询问通知许可,并检查推送通知的证书是否完美 –
@DithithMinura yes。弹出权限弹出。 –