【发布时间】:2019-01-23 03:31:36
【问题描述】:
我们正在使用 APNS 向外部设备发送推送通知。有效载荷如下所示:
{
"data":{
"aps":{
"alert":{
"loc-args":["bharathp"],
"loc-key":"LiKudoAlertBody",
"title-loc-key":"LiKudoAlertTitle"
}
},
"fromName":"bharathp",
"source":"community",
"type":"kudos",
"message":"{....some dictionary....}",
"fromId":"1696757163"
},
"to":"some string"
}
但在 iOS 上,当我收到通知时,我只会收到有效负载的“aps”部分。
[AnyHashable("aps"): {
alert = {
"loc-args" = (
bharathp
);
"loc-key" = LiKudoAlertBody;
"title-loc-key" = LiKudoAlertTitle;
};
}]
我正在使用
打印上述内容func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable : Any]) {
// Print notification payload data
print("Push notification received: \(data)")
}
我发送的格式不正确吗?这可能是什么问题?
【问题讨论】:
-
这不是 APNS 负载的标准格式,您是否使用 3rd 方服务来发送通知?
-
这不是标准格式。试试这样,{ "aps" : { "alert" : { "title" : "Manish Kumar", "body" : "iOS Developer" }, }, "data" : { //你的数据在这里 } }
标签: ios swift push-notification apple-push-notifications