I am working on App in which I am required to show notification. For notification, i am using FireBase Cloud Messaging (FCM). I am able to get Notification
Here is the easiest way to understand this.
When you send a data payload with the notification payload as
notification: {
title: "Your order status.",
body: orderStatusDetail,
clickAction: "ShopFragment"
},
data: {
ORDER_ID: orderId
}
The notification clickAction will be the filter you will use to pass data into your Activity, what data? The data sent by the data: { } object appended to the payload.
So, the clickAction will trigger the intent filter in your Manifest, so first we need to create it
Now we set the intent filter with the same name as our clickAction, doing this we trigger that whenever we press the notification at our notification tab, this intent filter will launch and so on the activity associated with this intent filter.
And then, just use intent.getStringExtra("ORDER_ID") at your MainActivity to get your String extra sent at your data payload.
Make sure that ORDER_ID in this case is the key we send from the data { } object and needs to be the same in the client to get this data.