android notification message is missing when app in background
Hi, when the app is in the foreground and im sending a message from notification/compose in firebase console I can see the notification.message LOG NOTIFICATION: {"finish": [Function finish], "foreground": true, "id": "XXXX", "message": "hello", "title": "hi there", "userInteraction": false}
when im doing the same on the background notification object is completely different and doesnt contain the message and title LOG ANDROID: background LOG NOTIFICATION: {"collapse_key": "com.XXX.XXX.app", "finish": [Function finish], "foreground": false, "from": "XXX", "google.delivered_priority": "high", "google.message_id": "XXX", "google.original_priority": "high", "google.sent_time": 1579167945857, "google.ttl": 2419200}
in ios everything works fine both scenarios (but to ios i dont send messages from firebase console.
any idea why?
Thanks, Oded.
I figured out how to fix it, when you send a message through your client (not FCM console) instead of sending just var payload = { notification: { title: title, body: message } };
add data: var payload = { notification: { title: title, body: message }, data: { title: title, body: message } };
and the message and title will be seen when you click on the notification if you were in the background.