Repeating iOS Notification

71 Views Asked by At

Is there any way to schedule local notification which fires at specific date and the repeats every minute? Example: user receive first notification at 8:00 AM and then 8:01, 8:02...

1

There are 1 best solutions below

1
LLIAJLbHOu On

To schedule repeated notification you need date components in trigger initialization.

e.g.

let date = Date(timeIntervalSinceNow: 3600)
let triggerDaily = Calendar.current.dateComponents([.hour,.minute,.second], from: date)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDaily, repeats: true)

trigger repeats notification daily

try to setup trigger using only .second in date components

let date = Date(timeIntervalSinceNow: 3600)
let triggerDaily = Calendar.current.dateComponents([.second], from: date)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDaily, repeats: true)