Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
Firebase background message handler not triggered in react

I am trying to send data to the my app using firebase messaging. I receive the notification, but the background handler is never triggered on the app.

This is how I send the message

     await admin.messaging().sendToDevice(
        usersToken,
        {
            notification: {
                title: title,
                body: body,
                sound : 'default'
            },
            data:{
                test: 'hello',
            }
        },
        {
      // Required for background/quit data-only messages on Android
      priority: 'high',
},
);

And the react code I tried to implement the handler inside and outside the App function, but none worked.

In App.tsx

/**
 * This is the root component of our app.
 */
function App() {

}

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

AppRegistry.registerComponent('app', () => App);

Second try:

/**
 * This is the root component of our app.
 */
function App() {

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

AppRegistry.registerComponent('app', () => App);
}

I receive the notification on the device, I get no errors, but the background handler is not triggered.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!