My requirement is prevent remote notification from being display.
I can handler this if app is in foreground or background in following methods:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
//logic hide notification here
}
public func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
//logic hide notification here
}
When app is being killed, I'm trying to handler logic in UNNotificationServiceExtension but it did not work:
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
// logic hide notification here
}
I've read this article: Is it possible to prevent a remote notification from being displayed? It said that Apple not allow to do this, is this correct?