我是iOS開發新手,但已經創建了該應用程序,並且正在嘗試爲特定時間(例如(10AM))創建每日通知。現在,如果我的移動設備時間到達上午10點,通知就會變得太多。我想在給定的特定時間點上午10點觸發本地通知,我想每天重複一次。每天重複通知的最佳方法是什麼?如何在特定時間每天在特定時間觸發本地通知3
這裏是我的代碼
func fire(){
let dateComp:NSDateComponents = NSDateComponents()
dateComp.hour = 10
dateComp.minute = 00
dateComp.timeZone = NSTimeZone.systemTimeZone()
let calender:NSCalendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierIndian)!
let date:NSDate = calender.dateFromComponents(dateComp)!
let localNotificationSilent = UILocalNotification()
localNotificationSilent.fireDate = date
localNotificationSilent.repeatInterval = NSCalendarUnit.Day
localNotificationSilent.alertBody = "Started!"
localNotificationSilent.alertAction = "swipe to hear!"
localNotificationSilent.timeZone = NSCalendar.currentCalendar().timeZone
localNotificationSilent.category = "PLAY_CATEGORY"
UIApplication.sharedApplication().scheduleLocalNotification(localNotificationSilent)
}
的可能的複製[在設定的時間以快速重複每日本地通知(http://stackoverflow.com/questions/30619998/repeating-local-通知 - 每天一個 - 設置 - 與 - 迅速) – sanman