我试图按照解析指南来处理我JSON格式发送通知,但我有一个问题,这里是我的代码:Xcode中,解析 - 处理远程通知
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
// Override point for customization after application launch.
Parse.setApplicationId("MyAppId", clientKey: "MyAppClientKey")
var notificationType: UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
var settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationType, categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
UIApplication.sharedApplication().registerForRemoteNotifications()
if let launchOptions = launchOptions {
var notificationPayload: NSDictionary = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] as NSDictionary!
println(launchOptions)
var url = notificationPayload["url"] as String
var feed: FeedTableViewController = FeedTableViewController()
feed.messages.insert(url, atIndex: 0)
feed.sections.insert("section", atIndex: 0)
}
return true
}
的应用程序现在不会崩溃,但我所做的更改不会发生。 的Json代码:
{
"aps": {
"badge": 10,
"alert": "Test",
"sound": "cat.caf"
},
"url": "http://www.google.com"
}
请检查我的更新后,以及如果launchoptions ==更新了如何检查零零? – Abdou023 2014-10-07 20:27:54
,我不知道该怎么如果他们为零,你应该怎么做,我假设他们是零,应用程序不是通过打开一个通知,你应该继续。 – Logan 2014-10-07 20:34:17
这工作,但现在我不能让通知影响我的应用程序。请检查我的编辑。 – Abdou023 2014-10-07 21:09:31