Skip to content

Add WebView on iOS support with a note specifying the limitations - #30146

Open
Bashamega wants to merge 1 commit into
mdn:mainfrom
Bashamega:main
Open

Add WebView on iOS support with a note specifying the limitations#30146
Bashamega wants to merge 1 commit into
mdn:mainfrom
Bashamega:main

Conversation

@Bashamega

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API size:xs [PR only] 0-6 LoC changed labels Jul 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs).

Comment thread api/ServiceWorker.json
"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."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This note needs to explain what "works" means. I'd expect to see something like…

The ServiceWorker API 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…

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I don't know the particulars for it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NiklasMerz Do you know anything about this? Something worth recording in BCD?

If not, we'll close this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ddbeck ddbeck Aug 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, where do I set the domains for "App-Bound Domains"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API size:xs [PR only] 0-6 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

api.ServiceWorker - WebView on iOS does have support via App Bound Domains

4 participants