Add WebView on iOS support with a note specifying the limitations - #30146
Add WebView on iOS support with a note specifying the limitations#30146Bashamega wants to merge 1 commit into
Conversation
|
Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs). |
| "version_added": false | ||
| "version_added": "14", | ||
| "partial_implementation": true, | ||
| "notes": "Works only with App Bound Domains (up to 10 domains) and for apps with the Web Browser entitlement." |
There was a problem hiding this comment.
This note needs to explain what "works" means. I'd expect to see something like…
The
ServiceWorkerAPI is not exposed unless the webview is configured for app bound domains…
Or depending on the particulars, this data might somewhere else, e.g.,:
The
navigator.serviceWorker.register()method throws unless the webview is configured for app bound domains…
There was a problem hiding this comment.
Unfortunately, I don't know the particulars for it.
There was a problem hiding this comment.
@NiklasMerz Do you know anything about this? Something worth recording in BCD?
If not, we'll close this PR.
There was a problem hiding this comment.
I haven't used ServiceWorkers in WKWebView myself but this limitation seems to be correct. I found multiple sources and this WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=206741. That also states it's supported only for HTTP and HTTPs whereas some WebView developers (including Cordova, Capacitor) use custom schemes.
Supporting ServiceWorker only with AppBound domains and HTTP(S) is a serious limitation worth recording in BCD I think.
There was a problem hiding this comment.
Thank you, @NiklasMerz! One follow up: do you have any idea how the limitation manifests? The linked bug doesn't explain what lack of support means exactly (e.g., does "serviceWorker" in navigator return false? Is ServiceWorker exposed regardless? Or is there some kind of exception on registration?).
There was a problem hiding this comment.
It seems it is not exposed by default. However, I seem to have been testing in WKWebView 18.7. I filed WebView-CG/CanIWKWebView#7 on your repo.
There was a problem hiding this comment.
I'm pretty sure that's just some user agent lying from WebKit. If your iOS is up-to-date you are using the most recent version of WKWebView.
There was a problem hiding this comment.
OK, thank you! I enabled "Limit to App-Bound Domains" in your app's config but still no luck seeing ServiceWorker exposed. Do I also need "Web Browser entitlement"? How is that possible?
There was a problem hiding this comment.
Also, where do I set the domains for "App-Bound Domains"?
There was a problem hiding this comment.
You need to set the domains in Info.plist (there is an UI for that not sure what it's called from memory) and then webViewConfiguration.limitsNavigationsToAppBoundDomains = YES;
https://webkit.org/blog/10882/app-bound-domains/
(I tried AppBoundDomains many years ago but it didn't work for my use case so I'm not sure how it works today).
Summary
This PR adds webview on iOS support with a not specifying the limitations
Test results and supporting details
stackoverflow.com/a/64155509/3255152
webkit.org/blog/10882/app-bound-domains
Related issues
fixes #27470