wix / react-native-notifications

React Native Notifications
MIT License
3.25k stars 764 forks source link

Receiving warning "No task registered for key ReactNativeFirebaseMessagingHeadlessTask" #883

Closed javitolin closed 2 years ago

javitolin commented 2 years ago

As the title says, when I'm receiving a notification in the background, react-native logs a warning to the console specifying: No task registered for key ReactNativeFirebaseMessagingHeadlessTask

What am I missing in the configuration? I tried to look at it in the example but found nothing.. Thanks

javitolin commented 2 years ago

Found a fix. Need to

# Install & setup the app module
yarn add @react-native-firebase/app

# Install the messaging module
yarn add @react-native-firebase/messaging

And then add at index.js:

import messaging from "@react-native-firebase/messaging";

// Register background handler
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
  console.log("Message handled in the background!", remoteMessage);
});