Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Service Worker iOS Support

As Apple announced Service Worker support for iOS 11.3 a few months ago, I recently started trying to get a service worker to work on iOS. On Safari it works as expected, after vising the website, it works offline. However, when trying to use the same feature in Chrome, I had intermittent results. Specifically, the service worker would only work every other page refresh, with the original refresh after going offline being one of the ones not working.

I know that Chrome on iOS is built on a version of Safari, therefore I am confused about this behavior.

Is this due to incomplete support from Chrome iOS for Service Workers? Because it is Chrome on iOS, I'm not sure of any easy way to debug it either, so any other tips to help track down the problem would be appreciated. Thank you!

like image 656
Alex Baker Avatar asked May 30 '18 14:05

Alex Baker


People also ask

Do service workers work on iOS?

Apple is the last major platform to deliver service worker support, which means sites using service workers can deliver a faster, offline capable experience to end users. While there are some limitations compared to Safari, Edge and FireFox, you don't need to worry about overly degraded PWA experiences on iOS.

Do all browsers support service workers?

The first browser to implement service worker support was Chrome, but Opera, Firefox and the Samsung browser now support service workers.

What is the difference between service worker and web worker?

Unlike web workers, service workers allow you to intercept network requests (via the fetch event) and to listen for Push API events in the background (via the push event). A page can spawn multiple web workers, but a single service worker controls all the active tabs under the scope it was registered with.


1 Answers

Chrome for iOS do not support service workers currently(as of Apr-2020) and also the "Add to home screen" option is not available, if you are interested in that. Any offline page loading that you are experiencing should be from regular browser cache.

Here is an official documentation from Apple's web-kit page.

Update: A previous version of this post stated the Service Worker API is available in all applications using WKWebView. At this time it is only available in Safari, applications that use SFSafariViewController, and web applications saved to your home screen.

Notably, Chrome uses WKWebView as its browser engine in iOS, which don't have service worker support yet as per the above statement(which you can find in the link provided above). So the only way you can use Service worker in iOS is to use Safari browser or use one of the above supported web-views inside a native app.

Here is an article on what all PWA features iOS is still missing. Remember, this is a fast growing area. Always check if what is applicable now, especially if the documentation/article is getting older.

Here is an adapter to help debug in Chrome dev tools for pages loaded iOS - webkit/safari. Hope it becomes as easy as Android Chrome debugging one day!

like image 123
Anand Avatar answered Sep 17 '22 15:09

Anand