1
我想添加本地通知到我的遊戲。該代碼適用於iOS 8,但是當我嘗試在iOS 7上測試它時,它只會崩潰。迅速崩潰在iOS 7本地通知
這是註冊通知的代碼(其在App代表)
let notificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
let settings = UIUserNotificationSettings(forTypes: notificationType, categories: nil)
application.registerUserNotificationSettings(settings)
這是我的代碼來設置通知
UIApplication.sharedApplication().cancelAllLocalNotifications()
notification.fireDate = NSDate(timeIntervalSinceNow: 3600)
notification.alertBody = "Come back and play"
notification.alertAction = "to play"
notification.applicationIconBadgeNumber = 1
UIApplication.sharedApplication().scheduleLocalNotification(notification)
時,其登記的通知它崩潰。
有沒有辦法在iOS 7中使用本地通知 – Loanb222
它仍然會調用可選的func應用程序(_ application:UIApplication,didReceiveLocalNotification notification:UILocalNotification) – Dare