Home / IOS Development / Schedule local alerts to be repeated between two given times each day? : iOSProgramming

Schedule local alerts to be repeated between two given times each day? : iOSProgramming



I create an app that has a functionality to send a message every 30 minutes between a given time slot, for example 08.00 to 22.00 Now I have the code to ask for permission and send alerts from time to time, but I can not figure out how to contain them within a specific time frame.

let center = UNUserNotificationCenter.current()

let content = UNMutableNotificationContent()

content.title = "Content title"

content.body = "My content body."

content.categoryIdentifier = "alarm"

content.userInfo = ["customData": "fizzbuzz"]

content.sound = UNNotificationSound.default

let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1,800, repeats: true)

let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)

center.add(request


Source link