Unnotification with timedelay sometimes not working iOS swift
Solution:
I had faced the problem that i had give time for unnotification at a particular time like now or after few seconds.but sometimes it was not triggered.So i changed the code from
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDate, repeats: true)
To
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: TimeInterval(delay),
repeats: false)
It was working good. If you want to trigger a notification to current time use the above code or if you want to trigger a notification at next hour or some date then use the dae based trigger.
I had faced the problem that i had give time for unnotification at a particular time like now or after few seconds.but sometimes it was not triggered.So i changed the code from
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDate, repeats: true)
To
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: TimeInterval(delay),
repeats: false)
It was working good. If you want to trigger a notification to current time use the above code or if you want to trigger a notification at next hour or some date then use the dae based trigger.
Comments
Post a Comment