Service Workers and iOS/Safari

Service workers and iOS / Safari

Although Ian's answer was great by the time it was posted (04.2015), this question became important point of entry for a lot people interested in service workers and Progressive Web Apps and answer is much broader now.

Feedback from Apple

30.03.2018:
Service workers are shipped with Safari 11.1. Good job! https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_11_1.html

20.12.2017:
Service workers enabled by default in Safari Technology Preview 46
https://webkit.org/blog/8042/release-notes-for-safari-technology-preview-46/

04.08.2017:
Work officially in progress :) https://webkit.org/status/#specification-service-workers

07.2017:
More positive signals on webkit-dev:

Apple engineers from the WebKit team have been heavily involved in ServiceWorkers spec discussions over the past few years. Many of our concerns with the spec have been addressed, especially for Fetch service workers which generally don't run beyond the scope of pages that use them. While we have not done any implementation work, the "under consideration" in this case is meant literally. We actually are considering it.

06.2016:
According to Jake Archibald's 'Is ServiceWorker ready?' current status of iOS (Safari) is:

Under consideration, Brief positive signals in five year plan.

Please be aware, that it affects all browsers on iOS - due to Apple's limitations, Chrome on iOS is using WKWebView - the same rendering engine as Safari, and it's only a tiny wrapper around it, so it's limited to current functionalities.

Resources

The most recognized place of tracking current status of service worker is Jake Archibald's 'Is ServiceWorker ready?'.

There's another resource that gathers these information, providing more information on various Chromium builds, most popular in China and covering some more details: https://ispwaready.toxicjohann.com/

Controversies

Wide-scale debate about Apple participation in modern web features has been triggered after Nolan Lawson's article Safari is the new IE (06/2015) whose main point was that

In recent years, Apple’s strategy towards the web can most charitably be described as “benevolent neglect.”

The main argument of the opposing party was that service worker and the rest of offline/PWA features are not customer-centric - the focus of Safari development.

Some people are even more radical like Greg Blass in his article (07/2017) who states that

Apple treats web apps like second class citizens because they don’t generate money like native apps in the app store.

Common point is that Apple is falling behind other vendors (Chrome, Firefox, Edge) with developing features that'll improve web experience, but also has very slow pace of fixing critical bugs that makes some features technically unusable.

Can someone clarify IOS Safari Service Worker Support

I found the answer to my question by using https://jakearchibald.github.io/isserviceworkerready/demos/fetchevent/

connecting my iPad to my Macbook and debugging my iPad. I was eventually able to open the web inspector for the Service worker for that page, and the console.log showed the event passed in.

FetchEvent.clientID is present but a zero length string. As it happens I did the same thing on my (linux) Desktop using Chrome and its also a zero length string, BUT it has another parameter resultingClientId with what looks like a UUID in it. That parameter is not there in Safari.

The FetchEvent.request is there, and in particular the URL. So I can generate my own client id in the client (I am using Date.now().toString() as that is good enough for my purposes) for use in the service worker. In fact my site without a service worker was using the in the URLs I need to intercept already, so I am happy that I have a solution.

Workbox PWA on iOS 15 intermittently shows Safari cannot open the page when offline

It turned out the issue was that we had our PWA configured with "display": "minimal-ui" in the manifest.json. It has to be set to standalone or fullscreen instead.

We discovered this while looking at why all of our PWA's data was being deleted after seven days of inactivity. We thought the fact there was a manifest present and the PWA was saved in the home screen would be enough for Safari to remove the 7-Day Cap on All Script-Writeable Storage even if the display was set to minimal-ui. This wasn't the case: The PWA must be configured with "display": "standalone" or fullscreen for the cap to be removed.

Doing this also stopped the behaviour described above.

Update ServiceWorker without page reload on Safari

ServiceWorkerRegistration.update() is supported by all browsers that support service workers, and should accomplish what you want.

If you wanted to confirm for yourself that it's actually supported in Safari, try running

reg = await navigator.serviceWorker.ready
reg.update()

in Safari's JS console, with the Network panel open. You should see a request made for your service worker after you run that.



Related Topics



Leave a reply



Submit