Service workers and iOS / Safari

32,588

Solution 1

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.

Solution 2

I don't know if or when Chrome on iOS will support Service Worker, but it is definitely possible today with Cordova.

The Service Worker plugin on npm will let you use the API in Cordova apps on iOS.

Solution 3

I wrote an article calling out Apple on the topic:

https://m.phillydevshop.com/apples-refusal-to-support-progressive-web-apps-is-a-serious-detriment-to-future-of-the-web-e81b2be29676

It got retweeted by a couple key people, then posted on hacker news, and continued to get some good twitter activity. A week later, they started development on it. So - stay tuned, it's coming!

Solution 4

Answer to the @mcl If you change your code in the service worker:

self.addEventListener( 'install', function(){
  return self.skipWaiting( );
});

to the following code, it should work. I have changed all the variables as well so just copy paste it.

self.addEventListener('install', event => {
  console.log('Attempting to install service worker and cache static assets');
  event.waitUntil(
    caches.open(FILES_CACHE)
    .then(cache => {
      return cache.addAll(urlsToCache);
    })
  );
});

Solution 5

Service worker is available in Safari 11.1, which shipped March 29, 2018 with iOS 11.3 and macOS 10.13.4:

https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_11_1.html

Note:

Share:
32,588

Related videos on Youtube

Karol Klepacki
Author by

Karol Klepacki

T-shaped commando with front-end as a weapon of choice. While constantly improving coding craftsmanship, I'm excited and eager to participate in whole software development cycle. Currently fascinated with service workers and Progressive Web Applications Over 9 years of professional experience.

Updated on July 09, 2022

Comments

  • Karol Klepacki
    Karol Klepacki almost 2 years

    On Chromium's page about service workers there's noted that

    Service Workers are not supported by Chrome on iOS.

    I assume that it can be delivered to iOS using some cordova plugins. Is there any other way to use Service Workers on iOS devices?
    I'm worried about time between shipping new version on iOS and new version of cordova.

    Does anyone know if Chrome on iOS is going to support service workers in the future? :)

    • nelsonic
      nelsonic almost 8 years
      A year later, is this still the case? Where did you find this info on "Chromium's page about Service Workers" ...? My understanding is that Chrome on iOS is using WKWebView (i.e. WebKit) for loading and rendering content: developer.chrome.com/multidevice/ios/overview so until Apple implements ServiceWorkers Natively they won't be available in Chrome for iOS...
    • Karol Klepacki
      Karol Klepacki almost 8 years
      @nelsonic: Hi, I've edited my question for you :)
    • Chris Love
      Chris Love about 7 years
      Chrome on iOS is not really Chrome. It is a wrapper around the Safari webview. Its primary purpose is to make it easy for you map over your Chrome bookmarks, etc to iOS. Because of the nature of iOS Safari is the ONLY browser on the platform. All other 'browsers' are merely wrappers around the safari webview control. So service worker support is limited to weather Safari and the webview control in particular supports service workers.
    • Martin Joiner
      Martin Joiner about 5 years
      I have revived an issue from 2017 on the GitHub repo for caniuse.com? I have offered to help clarify the information around browser support for ServiceWorkers. github.com/Fyrd/caniuse/issues/3519 Give me a thumbs up or a comment if you support the idea.
  • Roel
    Roel almost 7 years
    Chrome on iOS is nothing but a wrapper around the Safari Webview, because Apple won't allow browser vendors to use there own engine on iOS (this is evil in my opinion). So when Webkit (Safari) has Service Workers on iOS, Chrome on iOS will have it too.
  • Yvonne Aburrow
    Yvonne Aburrow over 6 years
  • Yvonne Aburrow
    Yvonne Aburrow over 6 years
    it got a mention on The Register too theregister.co.uk/2017/08/04/…