Is it possible to cancel a pushed notification before displaying it on the users phone ?
I have some custom logic which decides whether a notification needs to be displayed/appear . Is it possible for me to control this behaviour from the client side ios/android code ?
2
Answers
Once a message is sent to Firebase Cloud Message, there is no way to cancel its delivery.
If your message contains only a
data
element and nonotification
, displaying the message is handled by your application code – so in that case you may be able to suppress its display there.Although the best way is to handle this is to cancel it on backend side, you still can add UNNotificationServiceExtension and override the didReceive method: