Categories
Javascript Uncategorized

How to Get Data from FCM while App is in Background in React Native?

The notifications module in React Native Firebase has support for both remote (FCM) and local notifications. Firebase Cloud Messaging (FCM) is a great way to notify users about something you want them to know. But you can do more instead of showing only the message to the client.

So, how do you get data from FCM while the app is running in the background in React Native?

This is handled appropriately by Firebase SDK. When the user taps on the notification, the app receives payload associated with that notification. Here’s the code you can use to do that error-free.

Once you add the above-mentioned set of codes and run the simulation, you get the desired results. Seems good! Comment how it works for you!