Prevent device notification client side with React Native Firebase when a FCM notification arrives (based on user preferences)

Viewed 336

I'd like to know if there any a way to prevent the device display a notification when a FCM message with a notification arrives, in case the user has decided to mute notifications and only have them arrive silently (making them act as data only messages, but being notification messages). I imagine like, in the handler/callback call a method to prevent the device notification and do extra processing afterwards.

I know I can use data only messages, but that approach would be harder since I must use multiple topics or token lists and somewhat more backend logic to achieve that.

Thanks

1 Answers

If the message contains a notification property, it is automatically handled by the OS when the app is not active. There is nothing you can do to prevent that.

As you said: if the message only contains a data property, it is always passed to your code for handling, and you can decide what to do with it. So that's the way to go if you want full client-side control over whether a notification is displayed for a message.

Related