Closed codeheart09 closed 2 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
The issue has been closed for inactivity.
Any updates on this issue? I am facing the same problem. The output varies depending on the type of event.
@ajaybushel Did you find any workaround? I am facing same issue.
@ashokkumar88 This is what I ended up doing:
if (notification) {
const {
payload: { action, title, body },
} = notification;
const action =
notification.payload["gcm.notification.action"] ||
notification.payload.action;
const title =
notification.payload["gcm.notification.title"] ||
notification.payload.title;
const body =
notification.payload["gcm.notification.body"] ||
notification.payload.body;
}
same issue +1 and When I receive a notification in the background, then open it to launch app, the Notification object does not have a title or body.
{
collapse_key: 'com.libeccio.xterio',
'gcm.n.analytics_data':
{ 'google.c.a.e': '1',
'google.c.a.c_l': 'test',
'google.c.a.udt': '0',
'google.c.a.ts': '1695199063',
from: '1022924363809',
'google.c.a.c_id': '6809650627476227774'
},
'google.message_id': '0:1695199063520892%c4b7d40ac4b7d40a',
'google.original_priority': 'high',
'google.ttl': 2419200,
from: '1022924363809',
'google.sent_time': 1695199063512,
'google.delivered_priority': 'high' }
there are no 'gcm.notification.title' key
@ajaybushel
@chenweigh As far as I remember, I had to pass the notification data in the "extraData" field or something from the notification hub itself. On iOS, the library properly picks up the title and body from notification.data
object but on Android, for some reason, it doesn't.
Because of this issue, we ended up sending notifications (using Azure Notification Hub) like:
{
"data": {
"title": "...",
"body": "..."
},
"payload": {
"title": "...",
"body": "..."
}
}
Once done, I was able to properly access the properties on both iOS and Android. Also, I wouldn't take this concretely as it has been sometime since I worked on this.
I have version 4.2.4 installed in Android 11.
When I receive a notification in the foreground, the Notification object does not have a title or body. I'm using FCM's test message.
This outputs:
As you can see, the message is present in the payload, but not in the object.
Because of this, the notification does not show up. Only workaround is to get the data from the payload and trigger a local notification.