No ServiceWorker management in Webview on IOS 12+
See original GitHub issueBug 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:
- Start an Expo Project with react-native-webview deps
- Add a Webview component opening this URL https://jakearchibald.github.io/isserviceworkerready/
- Launch your app in an IOS Simulator
- In your app, scroll to navigator.serviceWorker and click on “Test” link
- 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:
- Created 4 years ago
- Reactions:9
- Comments:8
Top GitHub Comments
Any updates on this?
It’s possible with App-Bound Domains & limitsNavigationsToAppBoundDomains = true