title: Unable to receive notification in foreground on Android 8 using react-native-firebase
body: <p><strong>I am unable to get notification in Foreground on Android 8 only. Also unable to get control on Background notification.</strong> <em>But on Android version below 8 working fine with current implementation.</em></p>
  
  <p><strong>Steps followed:-</strong></p>
  
  <ol>
  <li>Installing react-native-firebase plugin version 5.0.0 into application.</li>
  <li>Created project on firebase console and added google_service.json file into android/app folder.</li>
  <li>In AndroidManifest added below code:-</li>
  </ol>
  
  <blockquote>
  <pre><code>     &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;service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService"/&gt;
  
     &lt;receiver android:name="io.invertase.firebase.notifications.RNFirebaseNotificationReceiver"/&gt;
     &lt;receiver android:enabled="true" android:exported="true" android:name="io.invertase.firebase.notifications.RNFirebaseNotificationsRebootReceiver"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.BOOT_COMPLETED"/&gt;
            &lt;action android:name="android.intent.action.QUICKBOOT_POWERON"/&gt;
            &lt;action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/&gt;
            &lt;category android:name="android.intent.category.DEFAULT" /&gt;
        &lt;/intent-filter&gt;
     &lt;/receiver&gt;
     &lt;meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_launcher"/&gt;
     &lt;meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="test_app"/&gt;
  </code></pre>
  </blockquote>
  
  <ol start="4">
  <li>Below function is added on App.js page and calling in componentDidMountMethod():-</li>
  </ol>
  
  <blockquote>
  <pre><code>performNotificationOperations(){
    this.messageListener = firebase.messaging().onMessage((message: RemoteMessage) =&gt; {
      console.log("Message",message);
      alert("Notification Message Arrived");
      if(this.state.isLogin){
        const notification = new firebase.notifications.Notification()
                          .setNotificationId(message.messageId)
                          .setTitle(message.data.show_name)
                          .setBody(message.data.description)
                          .setData(message.data)
                          .android.setChannelId('test_app')
                          .android.setBigPicture(message.data.showImage)
                          .android.setPriority(firebase.notifications.Android.Priority.High);
        firebase.notifications().displayNotification(notification).catch(err =&gt; alert("Error On Message"));
      }
    });
    this.notificationListener = firebase.notifications().onNotification((notification: Notification) =&gt; {
      console.log("Notification=&gt;",notification);
      alert("Notification Arrived");
      if(this.state.isLogin){
        notification.android.setChannelId('test_app')
        notification.android.setBigPicture(notification._data.showImage);
        notification.android.setPriority(firebase.notifications.Android.Priority.High)
        firebase.notifications().displayNotification(notification).catch(err =&gt; alert("Error On Notification"));
      }
    });
    this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen: NotificationOpen) =&gt; {
      console.log(notificationOpen,"Opened listener");
      console.log(notificationOpen.notification._data.type,"notificationOpen");
      firebase.notifications().removeDeliveredNotification(notificationOpen.notification._notificationId)
      if(this.state.isLogin){
        if(notificationOpen.notification._data.type==='show'){
          Navigate.forward('myshowdetails', this._navigator, {show:notificationOpen.notification._data});
        }else if(notificationOpen.notification._data.type==='episode'){
          this.playEpisode(notificationOpen.notification._data.episodeToken);
          Navigate.forward('myshowdetails', this._navigator, {show:notificationOpen.notification._data});
        }
      }
    });
    firebase.notifications().getInitialNotification()
    .then((notificationOpen: NotificationOpen) =&gt; {
      if (notificationOpen) {
        alert('Initial Notification');
        console.log(notificationOpen,"notificationOpen");
        console.log(notificationOpen.notification._data.type,"notificationOpen");
        firebase.notifications().removeDeliveredNotification(notificationOpen.notification._notificationId)
        if(this.state.isLogin){
          alert('IS LOGIN TRUE');
          if(notificationOpen.notification._data.type==='show'){
            Navigate.forward('showdetails', this._navigator, {show:notificationOpen.notification._data});
          }else if(notificationOpen.notification._data.type==='episode'){
            this.playEpisode(notificationOpen.notification._data.episodeToken);
            Navigate.forward('showdetails', this._navigator, {show:notificationOpen.notification._data});
          }
        }
      }
    });
    firebase.messaging().getToken().then(token =&gt; {
      console.log("GCM Token====&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;",token);
      Global.GCM_TOKEN=token;
      // alert(token);
      if(Global.IS_USER_LOGIN){
        Util.saveFCMToken(token);
      }
    });
  }
  </code></pre>
  </blockquote>
  
  <ul>
  <li>Added bgMessage.js file to handle data messages and registered Headless JS service using AppRegistery.</li>
  </ul>
  
  <blockquote>
  <pre><code>    // @flow
  import firebase from 'react-native-firebase';
  // Optional flow type
  import type { RemoteMessage } from 'react-native-firebase';
  import type { Notification,NotificationOpen} from 'react-native-firebase';
  
  export default async (message: RemoteMessage) =&gt; {
      // handle your message
      // console.log("Message=&gt;",message);
      alert("Message Arrived");
      const notification = new firebase.notifications.Notification()
                        .setNotificationId(message.messageId)
                        .setTitle(message.data.show_name)
                        .setBody(message.data.description)
                        .setData(message.data)
                        .android.setChannelId('podpitara_app')
                        .android.setBigPicture(message.data.showImage)
                        .android.setPriority(firebase.notifications.Android.Priority.High);
      firebase.notifications().displayNotification(notification).catch(err =&gt; alert("Error in Background"));
      return Promise.resolve();
  }
  </code></pre>
  </blockquote>
  
  <ul>
  <li><strong>Headless JS service call:-</strong></li>
  </ul>
  
  <blockquote>
    <p>AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () =>
    bgMessaging);</p>
  </blockquote>
  
  <ul>
  <li><strong>Additional Information:-</strong></li>
  </ul>
  
  <blockquote>
    <p>Platform - Android</p>
    
    <p>node-version - v8.6.0</p>
    
    <p>react-native - 0.57.0</p>
    
    <p>react-native-firebase - 0.5.0</p>
  </blockquote>
  
  <ul>
  <li><p><strong>Problems facing</strong></p>
  
  <ol>
  <li><p>Unable to receive notification in Foreground in case of Android 8 only.</p></li>
  <li><p>In case of background/minimized state, want to show notification with big picture, but not getting control from where I can handle displaying notification.</p></li>
  <li><p>In case of debug mode application displaying image peroperly int notification tray, but in case of release its not showing image.</p></li>
  </ol></li>
  </ul>
  
  <p><strong>Please let me know, What I am doing wrong.</strong></p>