Reputation: 3265
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?
Upvotes: 1
Views: 1184
Reputation: 1018
FCM has two messages types: when your app is in the background.
so, You should send a format is Data Message to handle notification in onMessageReceived when the app is background or foreground
Upvotes: 2
Reputation: 4705
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"}
Upvotes: 1