title: How do I remove react native firebase notification click action on android?
body: <p>I am using react-native-firebase to set up foreground &amp; background push notifications in my application. I set it up according to the docs: <a href="https://rnfirebase.io/docs/v4.3.x/notifications/receiving-notifications#App-in-Foreground-and-background" rel="nofollow noreferrer">https://rnfirebase.io/docs/v4.3.x/notifications/receiving-notifications#App-in-Foreground-and-background</a></p>
  
  <p>The app has a <code>firebase.messaging().onMessage()</code> listener attached and when it receives a notification in foreground, I use <code>firebase.notifications.displayNotification(notification)</code> to display the notification.</p>
  
  <p>Then the <code>onNotificationOpened</code> listener receives the notification and navigates the user to a different screen.</p>
  
  <p>The problem is that, the notification object received from <code>onNotificationOpened</code> has an action <code>android.intent.action.VIEW</code> which launches the MainActivity every time it is clicked. I have no idea where this action string is coming from, since neither the client app nor the backend sets any click action.
  Also this <code>android.intent.action.VIEW</code> happens to be the intent filter action for my <code>MainActivity</code>.</p>
  
  <p>I don't want a ContentIntent action tied to my notification, I want my app to handle the navigation to the correct component.</p>
  
  <p>Also there is the problem that clicking on the notification unmounts and re-mounts my main component and that causes the notification listeners to be removed.</p>
  
  <p>I have tried setting MainActivity <code>android:launchMode=singleTop</code> in AndroidManifest but the activity still relaunches. I have also tried using <code>singleTask</code>, <code>singleInstance</code> and <code>standard</code></p>
  
  <p>This is my display notification function that is called <code>onMessage</code></p>
  
  <pre><code>export async function displayNotification(message: RemoteMessage) {
    try {
      const notification = new firebase.notifications.Notification();
  
      const { title, message: messageBody, ...messageData } = message.data;
  
      notification
        .setNotificationId(message.messageId)
        .setTitle(title)
        .setBody(messageBody)
        .setData({
          ...messageData
        })
        .setSound('default');
  
      if (isAndroid) {
        // Build a channel for notifications on Android
  
        const channel = await createAndroidChannel();
  
        notification.android
          .setBigText(messageBody)
          .android.setChannelId(channel.channelId)
          .android.setAutoCancel(true) // Remove on press
      }
  
      await notifications.displayNotification(notification);
      return notification;
    } catch (error) {
  
    }
  }
  
  </code></pre>
  
  <p>Expected result is: user has app in foreground > user receives push notification > clicks on notification > does NOT relaunch Main Activity but redirects to particular screen if needed via <code>onNotificationOpened</code> listener</p>
  
  <p>Actual result is: after user clicks on foreground notification > Main Activity is relaunched and Main screen re-mounts causing notification listeners to be removed.</p>