i have use the single notification , and this is my code: this is for register the local notification>>>
func registerLocal() {
let center = UNUserNotifi
Note that your code should works as expected! however, there is a little pitfall.
I think that I almost faced the exact same issue, after I tried to trace the pending notifications, I noted that the only notification that has been added is the last requested one. That's because you are calling in scheduleLocal()
function:
// not required, but useful for testing!
center.removeAllPendingNotificationRequests()
Well, it is good to remove any existing notification reminder requests, this would help preventing unnecessary duplicate notifications, but you should call it only once before calling scheduleLocal()
:
UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
// now you could call this function many times...
scheduleLocal()
simply, you don't want to delete each pending notification directly after adding it, instead you delete the whole previous pending notifications and add new ones.