title: React Native receive remote push notification only if app is in background
body: <p>I am using <a href="https://www.npmjs.com/package/react-native-push-notification" rel="nofollow noreferrer">react-native-push-notification</a> in my react-native app to receive the remote push notifications. Everything is working fine I am getting all notifications when the app is either in foreground or background. </p>
  
  <p>But I want the notifications to show only when the app is in the background. <strong>If the app is in the foreground it should not show the notification.</strong></p>
  
  <p>Any help will be really appreciated.</p>
  
  <p>My manifest file contains the following code:</p>
  
  <pre><code>  &lt;meta-data  android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_launcher" /&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.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.RNPushNotificationListenerService"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="com.google.firebase.MESSAGING_EVENT" /&gt;
        &lt;/intent-filter&gt;
    &lt;/service&gt;
  </code></pre>