[v2] Headless JS and react-native-navigation
Issue Description
Can we use Headless JS with react-native-navigation [v2]?
Android allows you to act on data-only messages when your application is closed or running in the background. This is particularly useful if you'd like to be able to show heads-up notifications to your user. To allow this to work, we make use of React Native's built-in Headless JS functionality.
bgMessaging.js
// @flow
import firebase from 'react-native-firebase';
// Optional flow type
import type { RemoteMessage } from 'react-native-firebase';
export default async (message: RemoteMessage) => {
// handle your message
return Promise.resolve();
}
index.js
AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => bgMessaging);
Steps to Reproduce / Code Snippets / Screenshots
https://rnfirebase.io/docs/v5.x.x/messaging/receiving-messages#4)-(Optional)(Android-only)-Listen-for-FCM-messages-in-the-background
Environment
- React Native Navigation version: 2.0.2578
- React Native version: 0.56
- Platform(s) (iOS, Android, or both?): both
- Device info (Simulator/Device? OS version? Debug/Release?): all
Hey @rendomnet , did you find any solution for this?
@rendomnet @saadqbal Can we reopen this issue if there isn't a solution?
Is there any solutions?
I got the solution myself. this codes is working
import { AppRegistry,Platform } from 'react-native';
import { Navigation } from 'react-native-navigation';
if(Platform.OS === 'android'){
AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => bgMessaging);
}
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setDefaultOptions({
// popGesture: false,
topBar: {
visible: false,
_height: 0,
drawBehind: true
}
});
Navigation.setRoot({
root: {
id: 'App',
stack: {
children: [
{
component: { name: 'Splash' }
}
]
}
}
});
});
doesn't works for me, how can i fix?
Any updates on this ?
I had the same issue and root cause was that message wasn't high priority.