更新时间:2023-01-16 17:49:36
//This method will parse push notification userinfo data
func parseNotification(userInfo: [AnyHashable: Any]) {
print(">>>parseNotificationCalled ")
if let notification = userInfo["payload"] as? String,
let jsonData = notification.data(using: .utf8),
let dict = try? JSONSerialization.jsonObject(with: jsonData, options: .allowFragments) as? NSDictionary {
//This is the point where we need to save push notification
savePushNotification(payloadDict: dict ?? [:])
print("APS PAYLOAD DICTIONARY \(dict)")
}
就我而言,有效载荷字典采用字符串格式.解决了.
As in my case payload dictionary coming in string format. Solved.