1

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)

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)
    }
}
Abdou023
  • 1,654
  • 2
  • 24
  • 45

1 Answers1

1

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)
    }
}
Logan
  • 52,262
  • 20
  • 99
  • 128
  • Yup, that worked perfectly, can i add as much data as i want? for example: "url", "date", 'category" Also hot to implement it in the didLaunchWithOptions function ? – Abdou023 Oct 09 '14 at 23:31