ios9.1在一个帖子中调用两次UILocalNotification

时间:2015-11-20 12:30:53

标签: uilocalnotification ios9.1

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

0 个答案:

没有答案