PWA push notifications on iOS

Hi all,

I have a PWA with notification system working well on any other device including MacBook.

But my customers start to complain that they don't receive any notification on their iphone.

I checked with a friend iPhone XR with iOS 16.5.1 installed on it. And it seems that web push notifications are still deactivated in the experimental features.

Is it normal? Did I mis something? Apple said they delivered webpush API on iOS16 but it's deactivated by default.

I can not ask my customers to go there to activate the option is it a solution to override this or do we still need to wait 10 years to get it activated?

Thanks in advance

Replies

As of iOS 16.4 and iPadOS 16.4, Web Push is supported in web apps added to the Home Screen, and is enabled by default.

You can read more here and here

Note: Web Push is not supported inside Safari on iOS, and the experimental settings you noticed are only about Safari.

A typical feature based detection uses "PushManager" in window and showNotification" in ServiceWorkerRegistration.prototype to check whether a browser supports notifications and eventually display the "You need to add the site to the Home to get notifications". With the Safari experimental settings (Push API and Notifications) disabled though these two checks fail and there's no way to distinguish between this case and a browser which simply does not support this technology.

Is there a workaround or another requirement?

Also, even if I add the site to the Home Page, even with a Manifest (which I'm sure is loaded as the background color changes), both checks above still fail. Is there another requirement to make feature based detection work, maybe something in the Manifest?

Thanks!

  • Regarding my second question, the Manifest needs to declare "display": "standalone" (or "fullscreen") for the Push API and Notifications to work. Once this is done I can actually subscribe to the notifications and receive them (!).

    I still haven't a workaround for the first issue, the feature based detection. I'd rather avoid checking the iOS version, and I don't think it's even possible on the iPad. Help is welcome. Thanks!

Add a Comment

I've resorted to checking navigator.userActivation, which was also added in 16.4, as a workaround to display the "Add to Home Page" message.