I am using firebase push notification and also my android device get notification too. if I get notification, while app is open and I can read "title" and "Message" and it take me to "UserDetailsActivity" a specific class .But I also want to do the same thin on click the the notification. But when click on the notification it doesn't open the "UserDetailsActivity" and it open launchering clas and i can't read the message . Any one have solution for it?
firebaseService class
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService { private static int count = 0; @Override public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); Log.d(TAG, "From: " + remoteMessage.getFrom());
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
startService(new Intent(getApplicationContext(),UserDetailsActivity.class));
/* Message data payload: Message Notification Body: */
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
}
}
*androidMainfest
<service
android:name=".backgroundService.FirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
On launcher activer
if (getIntent().getExtras() != null) {
for (String key : getIntent().getExtras().keySet()) {
String value = getIntent().getExtras().getString(key);
Log.d(TAG, "Key: " + key + " Value: " + value);
}
}