【发布时间】:2022-01-22 23:58:48
【问题描述】:
我在 react native 中使用了 PushNotification 库。我到达时在我的设备中使用数据对象 json 在前台接收通知有效负载。但是在终止模式下,当我使用 (notification.userInteraction) 单击通知时,收到的对象数据仅包含标题和声音名称。你能帮我获取数据对象吗其中包含(引用键和开始)并认为:)
if (notification.userInteraction) {
}
if (notification.userInteraction) {
// Handle notification click
// alert('good');
alert(JSON.stringify(notification));
let notif=notification.data.aps.data;
let id=notif.id;
// alert("notificatin="+id);
}
酒吧
{"pn_apns":{
"aps":{
"alert": {
"body": "TEST",
"title": "TEST1"
},
"sound": "beep.wav",
"data": { "reference": "ND1004332", "startstation": "" }
},
"pn_push":[
{
"push_type":"alert",
"auth_method":"token",
"targets":[
{
"environment":"development",
"topic":"com.oui.fr"
}
],
"version":"v2"
}
]
}
}
【问题讨论】:
-
抱歉,我听不懂英文。您是说当应用程序处于前台时此有效负载被传递到您的应用程序,但是当应用程序被用户终止时,通知没有传递?就像你什么都没看到?
-
我通过我的设备发送了通知 ios 它工作正常通知中收到的数据但是在终止模式下找不到或未收到数据
-
我使用 notification.userInteraction 通过点击显示通知 json 对象
标签: ios react-native push-notification