我希望我的应用程序每天晚上13点通知用户。我把它放在我的app委托中:
func Notification() {
var Notification = UILocalNotification()
Notification.alertAction = "New Question!"
Notification.alertBody = "Solve the new question!"
Notification.fireDate = NSDate(timeIntervalSinceNow: 0)
UIApplication.sharedApplication().scheduleLocalNotification(Notification)
}
并且在我的应用程序中有了didFinishLaunching:
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Badge | UIUserNotificationType.Sound, categories: nil))
我必须做什么才能确保我的通知每天都会启动?
答案 0 :(得分:0)
只设置过去的日期,晚上13点,
并将repeatInterval设置为.CalendarUnitDay
notification.repeatInterval = .CalendarUnitDay;
notification.fireDate = NSDate(timeIntervalSince1970: 60*60*10)