В моем приложении я реализовал функцию проверки версии приложения с помощью строки bundleVersion. Теперь я хочу запускать эту функцию каждый день в 8:00 утра. Это приложение на основе киоска, которое не переходит в фоновый режим. Таким образом, приложение будет активным все время.
Я использую UILocalnotification
, чтобы запланировать уведомление на это время. Теперь в моем приложении есть и другие UILocalnotification
. Я не уверен, как я могу идентифицировать уведомления в методе делегата приложения didReceiveLocalNotification()
.
Мой способ запланировать уведомление ниже
func scheduleNotification() {
//UIApplication.sharedApplication().cancelAllLocalNotifications()
let notif = UILocalNotification()
let calendar = NSCalendar.currentCalendar()
let date = NSDate()
var calendarComponents = NSDateComponents()
calendarComponents = calendar.components([.Day,.Month,.Year], fromDate: date)
let day = calendarComponents.day
let month = calendarComponents.month
let year = calendarComponents.year
calendarComponents.day = day
calendarComponents.month = month
calendarComponents.year = year
calendarComponents.hour = 8
calendarComponents.second = 0
calendarComponents.minute = 0
calendar.timeZone = NSTimeZone.systemTimeZone()
let dateToFire = calendar.dateFromComponents(calendarComponents)
notif.fireDate = dateToFire
notif.timeZone = NSTimeZone.systemTimeZone()
notif.repeatInterval = NSCalendarUnit.NSWeekdayCalendarUnit
UIApplication.sharedApplication().scheduleLocalNotification(notif)
}
Любая идея будет оценена.