question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No ServiceWorker management in Webview on IOS 12+

See original GitHub issue

Bug description:

I have an application built with Expo which needs to use serviceWorker within Webviews. I used to handle this with basic Webviews from React Native which had the possibility to specify usage of WKWebview or UIWebview. By default on IOS, UIWebview was used and serviceWorker worked well since IOS 11.3 or 11.4

I upgraded Expo and React Native versions until I had to migrate to react-native-webview. Since I did, serviceWorker stopped working on IOS 12+.

It appears that in the navigator spawned by react-native-webview, navigator.serviceWorker is undefined. I found a pretty old post on Webkit site (with an update) specifying that:

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.

  • does react-native-webview use SFSafariViewController or something else ?
  • if it’s not already there, will react-native-webview provide a way to use ServiceWorker in an IOS app ?
  • Am I missing something ?

To Reproduce:

  1. Start an Expo Project with react-native-webview deps
  2. Add a Webview component opening this URL https://jakearchibald.github.io/isserviceworkerready/
  3. Launch your app in an IOS Simulator
  4. In your app, scroll to navigator.serviceWorker and click on “Test” link
  5. You’ll be redirect to a test page with this following result meaning that serviceWorker is not defined : navigator.serviceWorker,

Expected behavior: Having ServiceWorker working in Webviews within IOS app. Following steps, having this as result : navigator.serviceWorker, [object ServiceWorkerContainer]

Environment:

  • OS: IOS
  • OS version: 12+ (probably 11.4+, 12 and 13 tested)
  • react-native version: 0.59+
  • react-native-webview version: 7.0.5, 7.4.3 (installed with expo command on sdk 35 and 36), 8.0.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:8

github_iconTop GitHub Comments

1reaction
edsonaylloncommented, Oct 19, 2020

Any updates on this?

0reactions
GuySerfatycommented, Jul 3, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

No ServiceWorker management in Webview on IOS 12+ #1086
I have an application built with Expo which needs to use serviceWorker within Webviews. I used to handle this with basic Webviews from...
Read more >
Intermittently Service worker is n… | Apple Developer Forums
Working Scenario is : When we launch the application in online mode for the first time, it is successfully registering the ServiceWorker.
Read more >
WKWebView analog of service worker - ios - Stack Overflow
With service worker we show prompt to update web content. As were mentioned here service workers are not supported within WKWebView (or ...
Read more >
Service worker cache not shared when added to homescreen
On IOS 12, it appears the service worker is shared between Safari and the "Add to Homescreen" Webview but not the cache.
Read more >
977784 - WebView + Chrome 75 ServiceWorker failing all ...
Requests made via the Service Worker succeed when the network is present, and fail when the network is not available. State is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found