title: react native firebase - onNotification callback is not triggered when app is in foreground Android
body: <p>I am receiving message from fcm and firebase.notifications().onNotificationOpened is working fine while app in background but firebase.notifications().onNotification is not triggered when app in foreground</p>
  
  <p><strong>Androidmanifest.xml:</strong></p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.knowledgeupdateapp"&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
      &lt;uses-permission android:name="android.permission.RECORD_AUDIO"/&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
  
      &lt;!-- &lt; Only if you're using GCM or localNotificationSchedule() &gt; --&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
      &lt;permission
          android:name="com.knowledgeupdateapp.permission.C2D_MESSAGE"
          android:protectionLevel="signature" /&gt;
      &lt;uses-permission android:name="com.knowledgeupdateapp.permission.C2D_MESSAGE" /&gt;
      &lt;!-- &lt; Only if you're using GCM or localNotificationSchedule() &gt; --&gt;
  
      &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/&gt;
      &lt;uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/&gt;
  
      &lt;application
        android:name=".MainApplication"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:allowBackup="false"
        android:theme="@style/AppTheme"&gt;
        &lt;activity
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
          android:windowSoftInputMode="adjustResize"
          android:launchMode="singleTop"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
        &lt;/activity&gt;
        &lt;activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /&gt;
  
        &lt;meta-data android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"/&gt;
  
        &lt;meta-data android:name="com.google.android.geo.API_KEY"
          android:value="&lt;Removed APIkey&gt;"/&gt;
  
  
        &lt;meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
                  android:value="YOUR NOTIFICATION CHANNEL NAME"/&gt;
        &lt;meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
                      android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/&gt;
        &lt;!-- Change the resource name to your App's accent color - or any other color you want --&gt;
        &lt;meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                      android:resource="@android:color/white"/&gt;
  
  
        &lt;receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" &gt;
        &lt;intent-filter&gt;
            &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
            &lt;category android:name="com.knowledgeupdateapp" /&gt;
        &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
      &lt;receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" /&gt;
      &lt;receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"&gt;
        &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
        &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
      &lt;service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/&gt;
  
      &lt;service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm" android:exported="false" &gt;
        &lt;intent-filter&gt;
          &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
        &lt;/intent-filter&gt;
      &lt;/service&gt;
  
      &lt;service
      android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" &gt;
        &lt;intent-filter&gt;
            &lt;action android:name="com.google.firebase.MESSAGING_EVENT" /&gt;
        &lt;/intent-filter&gt;
      &lt;/service&gt;
  
      &lt;service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService"&gt;
          &lt;intent-filter&gt;
            &lt;action android:name="com.google.firebase.MESSAGING_EVENT" /&gt;
          &lt;/intent-filter&gt;
      &lt;/service&gt;
      &lt;service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService"&gt;
        &lt;intent-filter&gt;
          &lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT"/&gt;
        &lt;/intent-filter&gt;
      &lt;/service&gt;
  
   &lt;!-- Background Messages (Optional) --&gt;
  
    &lt;service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" /&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>App.js</strong></p>
  
  <pre><code>import React, {Component} from 'react';
  import {
    StyleSheet,
    Dimensions,
    Platform,
    View,
    StatusBar,
    DrawerLayoutAndroid,
  } from 'react-native';
  import { createStore } from 'redux';
  import { Provider } from 'react-redux';
  import DropdownAlert from 'react-native-dropdownalert';
  
  
  import reducer from './app/Redux/reducers';
  import { setNavigator, setActiveRoute } from "./app/Redux/actions";
  import DrawerContent from './app/Navigation/DrawerContent';
  import Toolbar from './app/Navigation/Toolbar';
  import AppNavigation from './app/Navigation/AppNavigation';
  import { bgStatusBar, bgDrawer } from './app/global.styles';
  import { ScrollView } from 'react-native-gesture-handler';
  import firebase from 'react-native-firebase';
  
  let store = createStore(reducer);
  /* getDrawerWidth       Default drawer width is screen width - header width
  * https://material.io/guidelines/patterns/navigation-drawer.html
  */
  const getDrawerWidth = () =&gt; Dimensions.get('window').width - (Platform.OS === 'android' ? 56 : 64);
  
  export default class App extends Component {
    constructor() {
      super();
  
      this.drawer = React.createRef();
      this.navigator = React.createRef();
    }
  
    async componentDidMount() {
      store.dispatch(setNavigator(this.navigator.current));
  
      //this will get initial notification
      // when can we use this: this can be use if app running in background at that time
      // we receive notification, during on tap of notification we will get data
      const notificationOpen = await firebase.notifications().getInitialNotification();
      console.log("--", notificationOpen)
      if (notificationOpen) {
        const action = notificationOpen.action;
        const notification = notificationOpen.notification;
        var seen = [];
        // if you send custom data in additional option you can access those data like below
        alert(JSON.stringify(notification.data, function(key, val) {
            if (val != null &amp;&amp; typeof val == "object") {
                if (seen.indexOf(val) &gt;= 0) {
                    return;
                }
                seen.push(val);
            }
            return val;
        }));
      }
      const channel = new firebase.notifications.Android.Channel('test-channel', 'Test Channel', firebase.notifications.Android.Importance.Max)
                  .setDescription('My apps test channel');
  
      // Create the channel
      firebase.notifications().android.createChannel(channel);
  
      this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) =&gt; {
          // Process your notification as required
          // ANDROID: Remote notifications do not contain the channel ID. You will have to specify this manually if you'd like to re-display the notification.
          console.log("invoked display listener")
      });
  
      this.notificationListener = firebase.notifications().onNotification((notification) =&gt; {
        // Process your notification as required
        console.log("invoked onnotification listener")
  
        notification
            .android.setChannelId('test-channel')
        firebase.notifications()
            .displayNotification(notification);
  
      });
  
      this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) =&gt; {
        console.log("invoked notification open")
          // Get the action triggered by the notification being opened
          const action = notificationOpen.action;
          // Get information about the notification that was opened
          const notification = notificationOpen.notification;
          var seen = [];
          alert(JSON.stringify(notification.data, function(key, val) {
              if (val != null &amp;&amp; typeof val == "object") {
                  if (seen.indexOf(val) &gt;= 0) {
                      return;
                  }
                  seen.push(val);
              }
              return val;
          }));
          firebase.notifications().removeDeliveredNotification(notification.notificationId);
      });
  
      this.messageListener = firebase.messaging().onMessage((message) =&gt; {
        // Process your message as required
        console.log("message listener")
      });
    } 
  
    componentWillUnmount() {
        this.notificationDisplayedListener();
        this.notificationOpenedListener();
        this.notificationListener();
    }
  
  
  
    openDrawer = () =&gt; {
      this.drawer.current.openDrawer();
    };
  
    closeDrawer = () =&gt; {
      this.drawer.current.closeDrawer();
    }; 
  
    getActiveRouteName = navigationState =&gt; {
      if (!navigationState) {
        return null;
      }
      const route = navigationState.routes[navigationState.index];
      // dive into nested navigators
      if (route.routes) {
        return getActiveRouteName(route);
      }
      return route.routeName;
    };
  
    render() {
      return (
        &lt;View style={{flex: 1}}&gt;
          &lt;Provider store={store}&gt; 
            &lt;DrawerLayoutAndroid
              drawerWidth={getDrawerWidth()}
              drawerPosition={DrawerLayoutAndroid.positions.Left}
              renderNavigationView={
                () =&gt; &lt;DrawerContent closeDrawer={this.closeDrawer} /&gt;
              }
              drawerBackgroundColor={bgDrawer}
              ref={this.drawer}
            &gt;
              &lt;View style={styles.container}&gt;
                &lt;StatusBar
                    translucent
                    backgroundColor={bgStatusBar}
                    animated
                /&gt;
                &lt;Toolbar showMenu={this.openDrawer} /&gt;
                &lt;AppNavigation
                  onNavigationStateChange={(prevState, currentState) =&gt; {
                    const currentScreen = this.getActiveRouteName(currentState);
                    store.dispatch(setActiveRoute(currentScreen));
                  }}
                  ref={this.navigator}
                /&gt;
              &lt;/View&gt;
            &lt;/DrawerLayoutAndroid&gt;
          &lt;/Provider&gt;
          {/* common notification component */}
          &lt;DropdownAlert ref={ref =&gt; global.dropDownAlertRef = ref}  closeInterval={2000} tapToCloseEnabled={true} /&gt;
        &lt;/View&gt;
      );
    }
  }
  
  const styles = StyleSheet.create({
    container: {
      flex: 1,
      backgroundColor: '#fff'
    },
  });
  </code></pre>