FCM when app in background
See original GitHub issueHi,
The FCM works fine when the app is in foreground and a push comes, but when the app is in background and the system tray notification is clicked , it just opens up the app without passing any intent extras. I have added the click_action
in Notification Payload from Advanced option of Firebase Console to open an activity but it dosen’t work. I have also added the intent-filter ( handle backgound app section) as in documentation.
How can i open a specific activity using FCM service along with the data i pass when the app is in background or exit state.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:9
- Comments:50 (5 by maintainers)
Top Results From Across the Web
How to handle notification when app in background in Firebase
When you are in background, FCM will showing notification in system tray based on the info from notification payload. Title, message, and icon ......
Read more >Receive messages in an Android app - Firebase - Google
When your app is in the background, Android directs notification messages to the system tray. A user tap on the notification opens the...
Read more >Firebase Notifications in Background & Foreground in Android
When the app is in foreground, the received messages are processed by the app, and since there's no logic to handle it, nothing...
Read more >How to handle FCM Push notification when app is in ... - GitHub
Question 1: Data messages (messages with no notification payload) are handled the same whether the app is in the foreground or background.
Read more >How to handle FCM notification in backgrounded Android ...
After setting up FCM in Android application, you can use Firebase console to send notifications. When foregrounded application receives a ...
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 @kroikie
I have a follow up question. According to this documentation, the notification will be delivered to the device’s system tray when the app is in background which means
onMessageReceived()
won’t get called, but I wonder if there’s any way that I can customize the icon in the notification view. Currently, it shows default white icon.After a deep search, I have found what is going on: There are two types of messages in FCM:
Firebase team have not developed a UI to send data-messages to your devices.
To achieve this, you have to do a
POST
to the following URL:And the following headers:
Content-Type
, Value:application/json
Authorization
, Value:key=<your-server-key>
Body:
To get your server key, you can find it in the firebase console: Your project -> settings -> Project settings -> Cloud messaging -> Server Key
Hope this helps!
Ref: How to handle notification when app in background in firebase