I have created a chat application using Firebase.
How to go to a particular chat activity, when clicked on a notification with message data?
I have created a chat application using Firebase.
How to go to a particular chat activity, when clicked on a notification with message data?
In your manifest file, you should declare the below intent filter for the activity that needs to be launched when an FCM notification is clicked :
<intent-filter>
<action android:name="NEW_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
And in your activity that launches when them notification is clicked, you can receive the data from the notification using bundle as below:
Bundle extras = notificationIntent.getExtras();
There are two types of FCM messages: Notification and Data.
The simple messages sent from the Firebase console are of type Notification. This means that when receiving the message in the background you can't control which Activity to open. BUT when receiving the message in the foreground OR sending a Data message (sent from the Cloud Functions or your app server), you can catch the message on onMessageReceived and create your own notification.
link to Firebase about receiving messages : Receive Messages in an Android App
link to Firebase about FCM messages : About FCM Messages
link about starting an Activity from a Notification : Start an Activity from a Notification