pusher / push-notifications-web

Beams Browser notifications
MIT License
39 stars 19 forks source link

undefined is not an object (evaluating 'window.safari.pushNotification') #110

Closed SanderGo closed 1 year ago

SanderGo commented 2 years ago

I've got the Web SDK working, with Laravel 9 / Vue3 / Inertiajs. After that I've spend the day implementing the Beams beta with safari/iOS support.

It works when I test it locally (and on staging) in Safari Tech Preview, User Agent set to Safari - iOS 16.0. I can trigger the notification permissions popup and subscribe. Even send notifications to my User ID.

I get errors when I test it on staging on my iPhone, remote debugging on my macbook with Safari Tech Preview (User Agent set to Safari - iOS 16.0 or even default).

Basically 2 errors:

Then nothing happens. I've cleared the website data, tried reloading the PWA, rebuild the js. The errors are too vague for me to get a clue what's going on.. spend a few hours on Google, but no luck..

Anyone got any ideas?

abu-samRah commented 1 year ago

Hi man

Were you able to solve this issue? I am currently facing the same problem. It works fine when testing locally but it gives the "TypeError: undefined is not an object (evaluating 'window.safari.pushNotification')" when trying on the staging environment .

SanderGo commented 1 year ago

Unfortunately the issue can't be solved at this moment, as there is not support for iOS at all.. only for Safari on desktop, that's why it works when testing locally but failing when testing on your phone.

I've asked the Pusher support team to make this more clear in the documentation. They said Apple will probably start supporting push notifications for PWA's on iOS somewhere in 2023, but for now there's no option for this.

My solution for now was to add email notifications for iOS users.

benw-pusher commented 1 year ago

@SanderGo is correct, iOS does not support web push notifications at this time. This is an iOS/Safari limitation and not a Beams limitation - if you need to push notifications to iOS devices then we do have a Swift library available, although you would need to build an app and publish to the App Store for this.