它可能与问题重复 -每天在设定的时间使用 swift 重复本地通知 但 UILocalNotifications 已弃用 iOS 10
我正在开发警报应用程序,我需要两件事 1. 一次本地通知 2. 间隔一段时间后重复
/// Code used to set notification
let content = UNMutableNotificationContent()
content.body = NSString.localizedUserNotificationString(forKey: titleOfNotification, arguments: nil)
content.userInfo=[]
工作正常的代码在准确的时间点击通知
/* ---> Working Fine --> how i can repeat this after 60 second if untouched
let triggerDaily = Calendar.current.dateComponents([.hour,.minute,], from: dates)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDaily, repeats: weekdays.isEmpty == true ? false : true)
*/
/// ---> Making it Repeat After Time - How Time is passed here ?
let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 60, repeats: true)
/// ---> Adding Request
let request = UNNotificationRequest(identifier:dateOfNotification, content: content, trigger: trigger) UNUserNotificationCenter.current().add(request){(error) in
if (error != nil){
print(error?.localizedDescription ?? "Nahi pta")
} else {
semaphore.signal()
print("Successfully Done")
}
}
我怎样才能同时实现这两件事?