0
votes

From Google documentation:

Handle notification messages in a backgrounded app

When your app is in the background, Android directs notification messages to the system tray. A user tap on the notification opens the app launcher by default.

But I need to handle tap and forward to my specific activity on my app (when app in background).

class CustomFirebaseMessagingService : FirebaseMessagingService() {


    /*-
        Call this method only when app is foreground.
     
    */
    override fun onMessageReceived(remoteMessage: RemoteMessage?) {

Method onMessageReceived called only when app is in foreground.

1
Where is your code ? What you tried ? - M D

1 Answers

1
votes

Firebase Cloud Messages supports two types of messages: notification messages and data messages.

Notification messages get handled by the OS when your app is backgrounded. There is nothing you can change about that.

What you can do is send a data message, which is delivered to your application's onMessage handler no matter whether the app is active or not. Since this onMessage can be called even when the app is not active, it is in a FirebaseMessagingService class and not in an Activity.

Also see the Firebase documentation on handling messages on Android.