gpt4 book ai didi

ios - APNS 中的自定义负载未交付

转载 作者:行者123 更新时间:2023-11-30 11:14:35 25 4
gpt4 key购买 nike

我们正在使用 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)")
}

我发送的格式是否不正确?这里可能出现什么问题?

最佳答案

也许是因为您使用的是已弃用的委托(delegate)方法。您可以尝试使用新的委托(delegate)方法。

@available(iOS, introduced: 3.0, deprecated: 10.0, message: "Use UserNotifications Framework's -[UNUserNotificationCenterDelegate willPresentNotification:withCompletionHandler:] or -[UNUserNotificationCenterDelegate didReceiveNotificationResponse:withCompletionHandler:] for user visible notifications and -[UIApplicationDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] for silent remote notifications")
optional public func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any])

关于ios - APNS 中的自定义负载未交付,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51872527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com