Remotely remove previously sent notification
Asked Answered
O

1

2

Since iOS 10 and UNUserNotificationCenter, a lot of things can be achieved with notifications, but I can't figure out how to remotely remove a push notification every time.

Using the mutable-content attribute, I'm able to modify the content of my push notification. But let's say I want to remove it later (the content has expired). I used content-available and then the following code:

UNUserNotificationCenter.current()
                        .removeDeliveredNotifications(withIdentifiers: [xxx])

It almost works, except (and that's a major problem) when the app was swiped out of memory by the user.

Has anyone found a way to remove notifications?

Outside answered 22/12, 2016 at 18:9 Comment(0)
P
0

As mentioned in this SO answer we have to send another push notification to clear previously sent notifications.

That notification should contain badge:0, and omit the alert and sound fields, then it will remove notifications from notification centre as well as clear app badge.

Prosper answered 11/9, 2017 at 11:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.