fabioshub / react-push-notification

Push notification library for React.js
46 stars 18 forks source link

Native push notifiation not working on mobile device (Chrome) #1

Open ase-dcexpert opened 4 years ago

ase-dcexpert commented 4 years ago

Hi,

showing notifications (version 1.3.0., native:true) on Windows 10 Chrome works fine. When loading the same page on my mobile device with Chrome, I get the following error:

Unhandled Rejection (TypeError): Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead.

The stack trace is:

Storage.<anonymous>

D:/VIDEOS/parfumo-souk-notifications/node_modules/react-push-notification/dist/notifications/Storage.js:54

(anonymous function)

D:/VIDEOS/parfumo-souk-notifications/node_modules/react-push-notification/dist/notifications/Storage.js:8

push../node_modules/react-push-notification/dist/notifications/Storage.js.__awaiter

D:/VIDEOS/parfumo-souk-notifications/node_modules/react-push-notification/dist/notifications/Storage.js:4

Storage.addNativeNotification

D:/VIDEOS/parfumo-souk-notifications/node_modules/react-push-notification/dist/notifications/Storage.js:48

Storage.<anonymous>

D:/VIDEOS/parfumo-souk-notifications/node_modules/react-push-notification/dist/notifications/Storage.js:81

(anonymous function)

D:/VIDEOS/parfumo-souk-notifications/node_modules/react-push-notification/dist/notifications/Storage.js:8

push../node_modules/react-push-notification/dist/notifications/Storage.js.__awaiter

D:/VIDEOS/parfumo-souk-notifications/node_modules/react-push-notification/dist/notifications/Storage.js:4

Storage.addNotification

D:/VIDEOS/parfumo-souk-notifications/node_modules/react-push-notification/dist/notifications/Storage.js:78

In my code I am just using the addNotification() function as described in the documentation here.

Thanks for helping and kind regards,

Alexander