应用程序在后台并且能够在forground接收时不能接收本地通知

时间:2016-10-14 07:06:22

标签: ios iphone swift ios9 unusernotificationcenter

didFinishLaunchingWithOptions method

let notificationSettings = UIUserNotificationSettings(
  forTypes: [.Alert, .Badge, .Sound], categories: nil)         
UIApplication.sharedApplication()
  .registerUserNotificationSettings(notificationSettings)

在sharedClass中

 let localNotification = UILocalNotification()
 localNotification.timeZone = NSTimeZone.localTimeZone()
 localNotification.fireDate = getNextDate(NSDate(), duration: "5")
 localNotification.alertBody = "Temp"
 localNotification.alertAction = "OK"

 UIApplication.sharedApplication()
   .scheduleLocalNotification(localNotification)

我能够进入前景,但无法进入后台。有人对此有所了解吗?

0 个答案:

没有答案