我正在使用react-native-push-notification npm包,并在app.But中获取本地和远程通知,但在显示远程通知时遇到问题。它是在onNotification函数中接收的,但不会在应用程序顶部显示。我希望它像本地通知一样。附上截图以获取更多说明:-
这是远程通知的blow代码
PushNotification.configure({
permissions: {
alert: true,
badge: true,
sound: true,
},
senderID: 'XXXXXXXXXX',
popInitialNotification: true,
requestPermissions: true,
onNotification: function(notification) {
console.log('REMOTE NOTIFICATION==>', notification);
},
onAction: function (notification) {
console.log("ACTION:", notification.data.action);
console.log("NOTIFICATION:", notification);
// process the action
}
}); 并且我在onNotification函数中成功接收远程通知,但这不像本地notification.Payload那样显示在屏幕顶部,远程通知如下:-
REMOTE NOTIFICATION==>{"data": {"action": "3", "alert": "Congrats! You have received food order. Click to see details", "content-available": "3", "job_id": "5f1a7301a1932d281023e7f4", "message": "Congrats! You have received food order. Click to see details", "sound": "default", "status": "3", "type": "FoodDelivery"}, "finish": [Function finish], "foreground": true, "id": "-1753177126", "userInteraction": false}
我想要显示远程通知,如本地通知,屏幕截图附在下面。任何帮助都将不胜感激。

谢谢
发布于 2021-05-01 20:34:48
从{"data": {...}} to {"notification": {...}}更改有效负载结构
https://stackoverflow.com/questions/63085391
复制相似问题