Google FCM getIntent return null on app is not running
See original GitHub issuePlease help me! I check debug this code extras alway return null when click on new notification, if app is not running, and show good on app is running
@Override
public void onNewIntent(Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
if (extras.containsKey("local_notification_message")) {
}
}
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
getIntent().getExtras() returns null FCM - Stack Overflow
Today, however, I sent a test notification, but tapping it did not perform the expected action. After some digging, I found out that...
Read more >Android – How to handle notifications with FCM when app is ...
Best Solution · Step 1. Override the "handleIntent()" instead of "onMessageReceived()" in FirebaseMessagingService · Step 2. Parse the message from FCM · Step...
Read more >Start an Activity from a Notification - Android Developers
To start a "regular activity" from your notification, set up the PendingIntent using TaskStackBuilder so that it creates a new back stack as ......
Read more >Handle FCM messages on Android - The Firebase Blog
When using an FCM notification message, the system handles showing the notification on behalf of your app when it's in the background.
Read more >Get new users for your app by enabling users to share your ...
Set up a new Firebase project and install the Dynamic Links SDK into your app. iOS · Android · C++ · Unity. Installing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
If your app is just in the background, onNewIntent would be called.
If your app is not running at all, the intent is normally passed through the onCreate, where you should handle it. Can you check this ?
Ben.
I am implementing FCM(Firebase messaging Service) in my application. Here all seems ok except when app is in background state i am not able to extract expected notification data.
here is concepts: There are two types of messages in FCM:
display-messages: These messages only work when your app is in foreground.
data-messages: Theses messages work even if your app is in background When our app is in the background, Android directs notification messages to the system tray.
for handling data-messages your notification should have click_action = “YOUR_ACTION” field.
My message will like this:
{ “data”: { “body”: “here is body”, “title”: “Title”, “click_action”: “YOUR_ACTION” }, “to”: “ffEseX6vwcM:APA91bF8m7wOF MY FCM ID 07j1aPUb” } The Activity will display the message that menifest file will like this:
<activity android:name=".NotificationActivity" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat.Dialog" android:windowSoftInputMode="stateHidden" >
After clicking on Notification it will redirect to my NotificationActivity . In my NotificationActivity in onCreate and onNewIntent method i am extracting message using this way:
Bundle bundle=getIntent().getExtras(); if(bundle!=null) { for (String key : bundle.keySet()) { Object value = bundle.get(key); Log.d(“DATA_SENT”, String.format(“%s %s (%s)”, key, value.toString(), value.getClass().getName())); } } Unfortunately in my NotificationActivity i am getting bellow message:
google.sent_time: 1471631793774
from: 50711789666
google.message_id 0:1471631793776823%098e508d098e508d
collapse_key: com.myapp.package_name
But where is my expected notification data?
Here is my system configuration:
Android Studio Version: 2.1.3
Firebase Version: com.google.firebase:firebase-auth:9.0.1
Google Play service version : com.google.android.gms:play-services:9.2.1