UILocalNotificaiton
在一个帖子中被调用两次。
有人知道原因吗?
我在iOS9.1中找到了它。但是在iOS8.0中它可以正常工作。
以下是我的代码:
extension UILocalNotification {
class func postNotification(message : String!, soundName : String?) {
dispatch_async(dispatch_get_main_queue()) { () -> Void in
let localNotification : UILocalNotification = UILocalNotification()
localNotification.fireDate = NSDate().dateByAddingTimeInterval(1)
localNotification.timeZone = NSTimeZone.defaultTimeZone()
localNotification.alertBody = message
localNotification.repeatInterval = NSCalendarUnit(rawValue: 0)
if soundName != nil {
localNotification.soundName = soundName
} else {
localNotification.soundName = UILocalNotificationDefaultSoundName
}
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
}
}
}