【发布时间】:2018-10-02 11:48:21
【问题描述】:
我是 iOS 新手,目前正在开发一款约会应用。我已经在 android 中实现了firebase push,它工作正常,但是当通知在 iOS 设备上出现时,它以原始json 格式出现。
通过搜索,我了解到 iOS 为推送通知提供了固定格式,例如:
{
"aps": {
"alert":"Testing.. (0)",
"badge":1,
"sound":"default",
"mutable-content": 1,
"attachment-url": ""
}
}
但我的json 数据以其他格式出现,我无法解析它以显示正确的通知。
My Format
{
"aps" : {
"badge" : 50,
"alert" : {
"body" : "{\"notificationId\":\"Flootapp\",\"DateMatchHistoryId\":\"BJgV-_PYX\",\"id\":\"Syn-XlnHX\",\"message\":\"Congratulations! You have a match with Rishi Raj. Confirm quickly\",\"type\":\"matched\"}",
"title" : "Floot"
}
},
"gcm.message_id" : "0:1537863976816788%835a2461835a2461",
"message" : "{\"notificationId\":\"Flootapp\",\"DateMatchHistoryId\":\"BJgV-_PYX\",\"id\":\"Syn-XlnHX\",\"message\":\"Congratulations! You have a match with Rishi Raj. Confirm quickly\",\"type\":\"matched\"}",
"badge" : "50",
"messageFrom" : "Floot",
"alert" : "{\"notificationId\":\"Flootapp\",\"DateMatchHistoryId\":\"BJgV-_PYX\",\"id\":\"Syn-XlnHX\",\"message\":\"Congratulations! You have a match with Rishi Raj. Confirm quickly\",\"type\":\"matched\"}",
"google.c.a.e" : "1"
}
我在这里缺少的任何东西。请帮忙。 提前致谢!
【问题讨论】:
-
能否提供您的 JSON 数据格式?
-
"我的 json 数据以其他格式出现" 还有什么其他格式?
-
@StacySmith 更新了我的格式。
-
@Larme 更新了我的格式。请看一看。
-
JSON 中有 JSON。你需要拨打
JSONSerialization就可以了。
标签: ios swift firebase push-notification firebase-cloud-messaging