react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

[v2] Headless JS and react-native-navigation

Open rendomnet opened this issue 8 years ago • 7 comments

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

rendomnet avatar Oct 11 '18 04:10 rendomnet

Hey @rendomnet , did you find any solution for this?

saadqbal avatar Jan 15 '19 05:01 saadqbal

@rendomnet @saadqbal Can we reopen this issue if there isn't a solution?

shivangp avatar Feb 01 '19 02:02 shivangp

Is there any solutions?

WASHSWATDAVID avatar Feb 17 '19 14:02 WASHSWATDAVID

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' }
          }
        ]
      }
    }
  });
});

WASHSWATDAVID avatar Feb 17 '19 15:02 WASHSWATDAVID

doesn't works for me, how can i fix?

diolegend avatar Apr 23 '19 23:04 diolegend

Any updates on this ?

johanschram avatar May 08 '19 19:05 johanschram

I had the same issue and root cause was that message wasn't high priority.

vstukanov avatar Oct 18 '19 10:10 vstukanov