【发布时间】:2020-07-25 07:02:42
【问题描述】:
我正在使用 react-native-push-notification npm 包并在应用程序中获取本地和远程通知。但是在显示远程通知时遇到问题。它在 onNotification 函数中收到,但未显示在应用程序顶部。我希望它像本地通知一样。附上屏幕截图以获得更多说明:-
远程通知的这个打击代码
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 功能中成功接收到远程通知,但这不像本地通知那样显示在屏幕顶部。远程通知的有效负载如下:-
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}
我想显示远程通知,例如下面附上的本地通知。任何帮助将不胜感激。
谢谢
【问题讨论】:
标签: react-native notifications react-native-firebase react-native-push-notification