我試圖按照解析指南來處理我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