I am getting a json from my server. my server json is
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print(userInfo)
}
this print result of userInfo
[AnyHashable("smallIcon"): small_icon, AnyHashable("tickerText"): , AnyHashable("message"): {"action":"new_content_notification","msg":{"headline":"iOS REFERRAL BONUS","subhead":"Congratulations. You have unlocked another BDT500 discount on long route trip booking.","brief":"Congratulations. You have unlocked another BDT500 discount on long route trip booking.","content_id":44}}, AnyHashable("subtitle"): www.ezzyr.com, AnyHashable("sound"): 1, AnyHashable("gcm.message_id"): 0:id, AnyHashable("aps"): {
"content-available" = 1;
},
AnyHashable("title"): Notification from ezzyr, AnyHashable("vibrate"): 1, AnyHashable("largeIcon"): large_icon]
i am converting this by using swifty json. after converting swity json i am gettng this
let fullInfo = JSON(userInfo)
print(fullInfo)
{
"gcm.message_id" : "0: some number",
"subtitle" : "www.someName.com",
"smallIcon" : "small_icon",
"largeIcon" : "large_icon",
"title" : "Notification from ezzyr",
"vibrate" : "1",
"message" : "{\"action\":\"new_content_notification\",\"msg\":{\"headline\":\"iOS REFERRAL BONUS\",\"subhead\":\"Congratulations. You have unlocked another BDT500 discount on long route trip booking.\",\"brief\":\"Congratulations. You have unlocked another BDT500 discount on long route trip booking.\",\"content_id\":69}}",
"sound" : "1",
"tickerText" : "",
"aps" : {
"content-available" : "1"
}
}
i want only data what i have in my message key. so i try to get message key value this way
let message = fullInfo["message"]
print(message)
after printing message i am getting this result
{"action":"new_content_notification","msg":{"headline":"iOS REFERRAL BONUS","subhead":"Congratulations. You have unlocked another BDT500 discount on long route trip booking.","brief":"Congratulations. You have unlocked another BDT500 discount on long route trip booking.","content_id":94}}
Than i was try to get the key value of "action" in this way.
let action = message["action"]
print(action)
but this time i am getting null value.. How can i fix this issue and get string value and also the key value of msg
Thanks advanced for help