Xcode - Push Notification Json

I would like to send a push notification to my application in Json format containing user data, but I do not know how to extract data from it or even if my json format is correct. (I think this is because Parse sends it successfully)

Json from Parse:

{ "aps": { "badge": 1, "alert": "Test", "sound": "" }, "url": "http://www.google.com" } 

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) } } 
+1
source share
1 answer

Try this instead:

 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) } } 
+1
source

Source: https://habr.com/ru/post/976382/


All Articles