Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase: Is it Possible to do custom notification for the FCM [duplicate]

I'm trying to do some customization regarding the FCM of firebase Notification. Is it possible to do it?

like image 824
DreamBigAlvin Avatar asked Dec 15 '22 05:12

DreamBigAlvin


2 Answers

Please, make a difference between Firebase Notifications and Firebase Cloud Messaging. https://firebase.google.com/support/faq/#notifications-difference

With notifications, you have small manoeuvre space. Key points are:

  1. If your app is in foreground, message will not be delivered to notification tray but in your service FireBaseMessagingService so you can do what ever you want with payload/notification.
  2. If your app is in background, your notification will be delivered to notification tray (with default look & feel) and FireBaseMessagingService will NOT be called. All payload you send via that push message will be delivered to intent user open via clicking on notification.
  3. So, in case of point 2, you can NOT customise notification according your needs.
like image 58
Bozic Nebojsa Avatar answered Dec 16 '22 19:12

Bozic Nebojsa


Yes it is possible Just override onMessageReceived in your service extending FireBaseMessagingService You get the data here in this function Then customize your notification using this data

like image 25
Yash Jain Avatar answered Dec 16 '22 18:12

Yash Jain