Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heads up notification using FCM

Do we have any way to show heads up notification, when receive push from Firebase Cloud Messaging? In foreground it is possible using Notification. But there is no way to show heads up notification, when app in background, because onMessageReceived is not calling.
I tried to set priority to "high", but no result.

Do you have any ideas?

like image 577
Andrii Chernysh Avatar asked Oct 26 '17 13:10

Andrii Chernysh


1 Answers

After browsing multiple solutions in stackoverflow.com, I found below explanation to be most helpful

How to handle notification when app in background in Firebase

  1. In your Android OnMessageReceived function/method, only Data Payload (RemoteMessage.getData) will trigger your custom notification such as head-up notification when App is in background. Notification Payload (RemoteMessage.getNotification) will not trigger your heads-up notification, and instead default to showing just a tiny icon on your notification tray.

  2. If you're using Firebase Cloud Functions, do check that the information you're sending through is in the data payload, and notification payload should be removed if you want the heads up notification to work. Having notification payload will default to showing just a tiny icon on the notification tray only.

Hope this piece of information helps, and happy coding.

like image 75
YYY Avatar answered Oct 17 '22 19:10

YYY