[这是Firebase的通知响应,它在字典中,我想访问“ fcm_options”,“ image”值。谁能指导我如何快速访问它。
"gcm.n.e" : "1",
"google.c.a.udt" : "0",
"google.c.a.e" : "1",
"gcm.message_id" : "1598126925155526",
"google.c.a.ts" : "1587313425",
"google.c.sender.id" : "162801098578",
"aps" : {
"alert" : {
"title" : "Test",
"body" : "Test"
},
"mutable-content" : "1"
},
"fcm_options" : {
"image" : "https:\/\/www.indiewire.com\/wp-content\/uploads\/2017\/12\/wonder-woman-759.jpg?w=759"
},
"google.c.a.c_id" : "3173813338411805539"
}
预先感谢
如果Dictionary
为,
let dict: [String:Any] = [
"gcm.n.e": "1",
"google.c.a.udt": "0",
"google.c.a.e": "1",
"gcm.message_id": "1598126925155526",
"google.c.a.ts": "1587313425",
"google.c.sender.id": "162801098578",
"aps": [
"alert": [
"title": "Test",
"body": "Test"
],
"mutable-content": "1"
],
"fcm_options": [
"image": "https://www.indiewire.com/wp-content/uploads/2017/12/wonder-woman-759.jpg?w=759"
],
"google.c.a.c_id": "3173813338411805539"
]
您可以从fcm_options
中获取image
和dict
,
if let fcmOptions = dict["fcm_options"] as? [String:Any], let image = fcmOptions["image"] as? String {
print(image)
//use image here...
}