How to schedule repeating local notification for a specific time interval

Viewed 54

I want to schedule local notification for every 3 hours difference.
But with one limitation, this should be between 7AM - 10PM

Code for scheduling.

let user = UNUserNotificationCenter.current()

let content = UNMutableNotificationContent()
content.title = "Local Notification"
content.body = "Test."

let trigger = UNTimeIntervalNotificationTrigger(timeInterval: (3*60*60), repeats: true)

let request = UNNotificationRequest(identifier: "id", content: content, trigger: trigger)

user.add(request) { (error) in print("Error")}
0 Answers
Related