如何解决在本机 iOS 应用程序上未收到仅数据通知
react-native-firebase/messaging onMessage() 方法不会从 FCM 向前台的 react-native iOS 应用程序发送纯数据通知。但是,如果我们发送数据 + 通知消息,它适用于 Android 应用程序和 iOS。仅通知消息在 iOS 和 android 上完全正常工作,对于仅数据消息出现此问题。
我使用真实设备对此进行了测试,并尝试将 content_available 参数与有效负载一起发送,但这对我不起作用。
package.json
"@react-native-firebase/app": "10.0.0","@react-native-firebase/crashlytics": "10.0.0","@react-native-firebase/messaging": "10.0.0"
Podfile
pod 'Firebase/Core'
pod 'Firebase/Firestore'
pod 'Firebase/Messaging'
有效载荷
{
"token":"TOKEN","data":{
"Nick" : "Mario","body" : "great match!","Room" : "PortugalVSDenmark"
}
}
App.js
async componentDidMount() {
//Get notification permission from user and token
await this.checkPermission();
messaging().onMessage(async remoteMessage => {
console.log("Remote notification inside onMessage" + JSON.stringify(remoteMessage));
});
messaging().onNotificationOpenedApp(remoteMessage => {
console.log('Notification caused app to open from background state:',remoteMessage);
});
// Check whether an initial notification is available
messaging().getInitialNotification().then(remoteMessage => {
if (remoteMessage) {
console.log(
'Notification caused app to open from quit state:',remoteMessage.notification,);
}
});
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。