Android push notification using FCM is unable to handle when application in background. Default message is displayed in notification tray.
Can Anyone help me how to handle the messages when application in background.
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
}
This method is not called when application is in background. Any help will be great help for me.
The onMessageReceived() will be always called if you receive the payload as "data" always from server.
Example : Payload from server should be like following :
{
"data":{
"id": 1,
"missedRequests": 5
"addAnyDataHere": 123
},
"to":"fhiT7evmZk8:APA91bFJq7Tkly4BtLRXdYvqHno2vHCRkzpJT8QZy0TlIGs......"
}
for more about this issue. Please refer following URL : Firebase onMessageReceived not called when app in background
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With