Failed to remove local notification from Lockscreen.

In my application, at some point I need to display some notification for the user, if the user did not respond to them, I need to delete this notification. Now, if I call the cancelAllLocalNotifications function, it removes the notification from the notification center (also removes the warning from the Home screen when the device is unlocked).

But when the device is locked and a notification is displayed on the lock screen. After a while, the application calls cancelAllLocalNotifications . Now this one does not remove Notification from the lock screen , however there is no element in the notification center.

+3
source share
2 answers

Usage cancelAllLocalNotificationswill not delete already shown. It cancels all notifications that are scheduled. I don’t think there is a way to remove the notification from the lock screen.

+1
source

I do not know if this was not possible, but now you can cancel the notification from the lock screen. If someone needs it now.

If you are sending a notification, you must keep it somewhere in order to be able to identify it when it should be canceled.

All you have to do is

UIApplication.sharedApplication().cancelLocalNotification(notification)

to identify a notification that should be canceled, you can set the information in the userinfo property

notification.userInfo = ["title": item.title, "UUID": item.UUID]
0
source

All Articles