Silencing some push notifications locally from the app

My use case : i want the app to completely silence a given received alert push notification, based on information the app has locally (completely remove it, and never even display it. Not just change the sound or badge).
So far i found no way of doing that :
  • notification service extension doesn't let you remove the notification entirely, just change its content.

  • Using "background / content" notification type then creating the notification locally doesn't work, since "background" notification type is unreliable by design.

  • voip notifications are banned from being used as a general-purpose background notification mechanism since iOS13

Help would be greatly appreciated.

Notifications have 2 components, the Service Extension which you described and more importantly-- if I understand what you're trying to do-- UNNotificationCenterDelegate which resides in your containing app.

In the method willPresentNotification return a value such as
Code Block
[UNNotificationPresentationOptions(rawValue: 0)]
in its completion handler






Additionally, my previous comment is the solution for a foreground application and that the Swift value:

Code Block
UNNotificationPresentationOptions(rawValue: 0)
equates to
Code Block
UNNotificationPresentationOptionNone

in Objective-C

https://developer.apple.com/documentation/usernotifications/unnotificationpresentationoptionnone?language=objc


Thanks, but the question was actually to silence a push notification handled by the service extension, not the app (aka : when the app is in background)

I have a similar situation, did you by any chance happen to find a solution for this? :)

Silencing some push notifications locally from the app
 
 
Q