How to set custom layout for those notifications which will be shown when app is in background?

Alireza Noorali :

I implemented the firebase cloud messaging (FCM) service in my app and I get notifications with my custom layout but just when the app is in the foreground and the reason is clear, It is because of existing setCustomContentView(myContentView) in onMessageReceived and we all know that onMessageReceived handle notification just when the app is in the foreground.

Now, I'm going to know is there a way to set the same custom layout for the notifications which will be shown when the app is in the background?

Dhaval Solanki :

I would advise to modify server code to receive data onMessageReceived in both foreground and background and ask sender to send only data payload without notification.

Here I have removed notification payload.

{"to":"[add your token]","data":{"title":"Working Good","body":"[add your message]"},"priority":"high"}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=94807&siteId=1