pusher / push-notifications-web

Beams Browser notifications
MIT License
39 stars 19 forks source link

Error on notification click handler #99

Open leandro-hermes opened 2 years ago

leandro-hermes commented 2 years ago

Sometimes when I click on a browser's notification, the event received by the handler doesn't have the data attribute, so I get the following error:

image

image

Note I'm using Beams inside an Angular project. So I imported the Beams' worker beside the already existing worker from Angular.

gurminder commented 2 years ago

I was facing same issue when I override PusherPushNotifications.onNotificationReceived in service worker for showing notification manually.

solution was to pass same params to notification data as PusherSDK passes as in this line https://github.com/pusher/push-notifications-web/blob/master/src/service-worker.js#L134

data: { pusher: { customerPayload: payloadFromCallback, pusherMetadata, }, }

@Pusher Beams Teams, it would be nice if you also implement something like PusherPushNotifications.onNotificationClicked and allow us to handle click logic without passing above data