HMS-Core/hms-cordova-plugin

NOTIFICATION_OPENED_EVENT payload doesn't have any data in it

gidifrancia opened this issue · 3 comments

Hi, i'm having issues try to recover the notification attributes, like title, message and custom data when a notification is clicked.
I send notifications using the Push Kit Console to my app.
The notifications are shown correctly, and if i click on a notification the app opens.

I tried listening to all the events , the only event raised is NOTIFICATION_OPENED_EVENT, with this payload:
{"dataOfMap":"{}","originalUrgency":"2","urgency":"2","ttl":"86400","sentTime":"0","receiptMode":"0","sendMode":"0","contents":"0","titleLocalizationArgs":"null","bodyLocalizationArgs":"null","ImageUrl":"null","Link":"null","NotifyId":"0","When":"null","LightSettings":"null","BadgeNumber":"null","Importance":"null","vibrateConfig":"null","visibility":"null","isAutoCancel":"true","isLocalOnly":"true","isDefaultLight":"true","isDefaultSound":"true","isDefaultVibrate":"true"}

This is the code i use to listen for events:
HmsPushEvent.onNotificationOpenedApp((result)=>{
console.log("NOTIFICATION_OPENED_EVENT",JSON.stringify(result));
})

the payload is the same for every notification i send.
If instead of a notification i send a data message the event is raised and the payload is filled correctly.

As you can see in the payload i get for EVERY notification i don't have title , message, notification_id, and more importantly the custom data fields i send with the notification.

the event NOTIFICATION_OPENED_EVENT is only raised if the app is already running. If the app is not running , no event is raised, and even if i try to get the initallNotification using the appropriate method, the method always return "Null" so i don't have any way to access the notification payload.

To recap:

  1. The event NOTIFICATION_OPENED_EVENT is raised with an empty payload, no notification data is passed
  2. getInitialNotification returns null even when the app is launched by a notification click

I'm using cordova 10 with android 9.0 and the lastest version of hms-cordova-plugin.
My app name is Gambero Nero (app id 102848669).

Can you help me? Thanks in advance

Hi jdf996,

Actually this version of cordova push, onNotificationOpenedApp event not working when application in kill state. So when you open the app with tapped notification from killed state, listener does not work and getInitialNotification return null. We are aware of both of these issues . We will fix it next release which at the end of October.

Ok thanks for the response.
Just to be clear, you're working also on the first point (The event NOTIFICATION_OPENED_EVENT is raised with an empty payload, no notification data is passed)?
If the app is opened, when i click on a notification the event NOTIFICATION_OPENED_EVENT is raised, but the payload does not have , data, title , notification id or any information on the notification.

Will the next release fix this problem as well?

Yes, we are working on both of them. And we will fix it next release. You will access the payload.