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.

feat: Implement App-Bound Domains to enable Service Workers in WKWebView on iOS14+

See original GitHub issue

Feature Request

Description

Since iOS14, it’s possible to make service workers works in WKWebView by providing a list of trusted domains (up to 10). These domains then gain support for service workers, which is invaluable for us as we plan to use server.url in production to distribute our PWA on iOS.

Here are links describing the possibilities and features :

Platform(s)

  • iOS

Preferred Solution

I think being able to pass the domain list with capacitor’s config file would be enough. Then capacitor could patch the Info.plist file with the domains, and build the WKWebView using the snippet provided in the first post I shared above :

let configuration = WKWebViewConfiguration()
configuration.limitsNavigationsToAppBoundDomains = true
// Create a WebView with this configuration

Alternatives

As of today I don’t think there is any alternative to support service workers in WKWebView

Additional Context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
thomasvidascommented, Dec 3, 2021

FYI, Ian no longer works at Ionic so he probably won’t answer 😄. To answer your question, here’s why we do not advise using a live server.url:

  • Capacitor apps lose the secure context for several web apis. In the config docs we list a few if you scroll down to the server.url option.
  • Apple has rejected apps that point to a live URL. Apple’s (and Google’s) app review process is pretty opaque so it’s hard to know exactly why they may reject one app that does this and approve another app. But in general, Apple is pretty clear that if your application is just an existing version of a website bundled in an app, they may reject it.
  • It is bad UX to point to an external server since if a user does not have internet access there is no functionality. By pointing to a localhost, the files are on the device. Meaning that even if your user has no internet access, the app is still functional.
0reactions
ionitron-bot[bot]commented, Nov 10, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

App-Bound Domains - WebKit
Many applications use WKWebView as a convenient way to display websites ... The App-Bound Domains feature takes steps to preserve user ...
Read more >
Will the AppStore accept apps rend… | Apple Developer Forums
In my testing over the first iOS/iPad14 beta, I've found that WKWebView with App-Bound Domains enabled, supports the Service Workers API on the...
Read more >
Service Workers unavailable in WKWebView in iOS 11.3
Service Workers in WKWebView now require an entitlement: com.apple.developer.WebKit. ... A better solution might be using App Bound Domains.
Read more >
Will iOS 14 support service workers in WKWebView?
But is kind of changing, and I believe the answer is "apps web browsers" may now enable the Service Worker entitlement, but other...
Read more >
Safari on iOS 14 and iPadOS 14 for PWA and Web Developers
Hello Service Worker #. Thanks to App-Bound Domains, browser apps with the browser entitlement will have app-bound domains enabled for the ...
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