In general, when i have notification message on the notification bar and click on it. It open the registered App for that message.
On Startup\'s Activity, How to de
I Had the same problem, and I don't understand why I have to use the putExtra method... So I solved like this: when you receive a notification and tap on it, the app will open (usually it opens the app main activity) and, in the extras, you can find some information about that notification. You can add key/value params to the notifications you're sending to registered devices. These params will be added to the intent extras.
So you can act like this: in your notification, add a parameter that represents your notification id.
For example "messageId" -> "abc", where abc is your notification identifier.
Then, in your main activity, you can do:
if (getIntent().getExtras().keySet().contains("messageId")) {
// you opened the app from a notification
String messageId = getIntent().getStringExtra("messageId");
// do domething...
} else {
// you opened the app normally
// do domething...
}
And you will retrieve the id of the notification. So you can use this information to, for example, get the notification from your db or other operations.