Answers for "how to schedule local notifications at specific time swift 5"

0

setting a local notification at specific time every day swift

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)
                    }
                }
Posted by: Guest on February-05-2021

Code answers related to "how to schedule local notifications at specific time swift 5"

Code answers related to "Swift"

Browse Popular Code Answers by Language