Estoy tratando de enviar datos a mi aplicación usando mensajes de firebase. Recibo la notificación, pero el controlador de fondo nunca se activa en la aplicación.
Así es como envío el mensaje.
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', }, );Y el código de reacción Traté de implementar el controlador dentro y fuera de la función de la aplicación, pero ninguno funcionó.
En aplicación.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);Segundo intento:
/** * 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); }Recibo la notificación en el dispositivo, no recibo errores, pero el controlador de fondo no se activa.