[英]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 simulator
或android 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. (在发布模式或调试模式下,两者都不起作用。
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 />;
}
}
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.如果您想在我的项目中获得更多环境或设置,请发表评论。
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.