Sorry for my title, but let me explain this. I use firebase cloud messaging on my apps. Now, I need run the apps then show the dialog contain notification body and title when the apps not running or in background, after I touch the notification.
For default FCM is when the apps not running/in background, I touch the notification then apps running/go to foreground.
Can anyone guide me to handle it?
From the FCM sample which launches the MainActivity when the notification is tapped:
EDIT:
In
onMessageRecieved(RemoteMessage remoteMessage)
method useremoteMessage.getData()
to get the data which is sent by server which returns aMap<String,String>
.Now create an Intent and specify a class to launch on click of notification and in this intent put your notification data. Like :
Now pass this intent to a pendingIntent when you show a notification.
And when MainActivity.class is launched on click of notification just get the data like this :
So from map you can get the data.