1
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)

我可以进入前台,但无法进入后台。有人对此有想法吗?

4

0 回答 0