Setting A Local Notification At Specific Time Every Day Swift

[Solved] Setting A Local Notification At Specific Time Every Day Swift | Swift - Code Explorer | yomemimo.com
Question : setting a local notification at specific time every day swift

Answered by : encouraging-eland-ol9hnz3fcuoq

let notificationContent = UNMutableNotificationContent()
notificationContent.title = "Title"
notificationContent.body = "This is a test"
notificationContent.badge = NSNumber(value: 1)
notificationContent.sound = .default
var datComp = DateComponents()
datComp.hour = 8
datComp.minute = 0
let trigger = UNCalendarNotificationTrigger(dateMatching: datComp, repeats: true)
let request = UNNotificationRequest(identifier: "ID", content: notificationContent, trigger: trigger) UNCenter.add(request) { (error : Error?) in if let theError = error { print(theError as! String) } }

Source : https://stackoverflow.com/questions/31821339/how-to-send-a-localnotification-at-a-specific-time-everyday-even-if-that-time-h | Last Update : Fri, 12 Feb 21

Answers related to setting a local notification at specific time every day swift

Code Explorer Popular Question For Swift