Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda