Xcode-推送通知Json [英] Xcode - Push Notification Json
本文介绍了Xcode-推送通知Json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想以包含自定义数据的Json格式向我的应用程序发送推送通知,但我不知道如何从中提取数据,甚至我的json格式是否正确. (我认为这是因为Parse发送成功)
I would like to send a push notification to my app in Json format containing custom data, but i don't know how to extract the data from it, or if even my json format is correct. ( i think it is because Parse sends it successfully)
来自Parse的Json:
Json from Parse:
{
"aps": {
"badge": 1,
"alert": "Test",
"sound": ""
},
"url": "http://www.google.com"
}
Appdelegate:
Appdelegate:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: NSDictionary!) {
var notificationPayload: NSDictionary = userInfo["url"] as NSDictionary!
if (notificationPayload["url"] != nil) {
var url = notificationPayload["url"] as String
var feed: FeedTableViewController = navigation.viewControllers[0] as FeedTableViewController
feed.messages.append(url)
feed.sections.append("url")
}else {
PFPush.handlePush(userInfo)
}
}
推荐答案
尝试以下方法:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: NSDictionary!) {
if let url = userInfo["url"] as? String {
var feed: FeedTableViewController = navigation.viewControllers[0] as FeedTableViewController
feed.messages.append(url)
feed.sections.append("url")
} else {
PFPush.handlePush(userInfo)
}
}
这篇关于Xcode-推送通知Json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文