developKinberg
developKinberg

Reputation: 383

Get payload data from FCM Message when app is in the background

I try to get the payload data from a fcm message, while my app is in the background. So I read this documentation and they say, I can get the data in the extras of the intent from my launcher activity, because if you click on the notification by default your launcher activity will open.

I send the message via the firebase console, then my app is in the foreground, I can handle all this via the onMessageReceived() method.

This is my code to achieve this, but the intent extras are null..

if (getIntent().getExtras() != null) {
 bundleFCM = getIntent().getExtras();

 for (String key : bundleFCM.keySet()) {
 Log.d(TAG, "payload keys: " + key);
 }
}

Upvotes: 0

Views: 806

Answers (1)

developKinberg
developKinberg

Reputation: 383

Okay my problem was, that I have a SplashActivity and the data payload was sent to this activity, so I transfer the data from the SplashActivity to my HomeActivity and all works fine.

Upvotes: 1

Related Questions