Service Workers
Service Worker enablement for your iOS and Android Apps
Service Workers are the modern standard for enabling offline functionality, background sync, and push-style caching on the web. If your website already uses a Service Worker for offline access, that same code can work inside your Median app but support differs meaningfully between Android and iOS, and iOS requires extra configuration.
Legacy NoteBoth platforms used to support the older HTML5 Application Cache Manifest for offline caching. That API is deprecated and no longer functions on iOS, so if you're migrating an older app, Service Workers are the only supported path forward on iOS.
Platform support
| Platform | Support | Setup required |
|---|---|---|
| Android | Full support | None, supported work out of the box |
| iOS 14+ | Supported with limitations | Requires App-Bound Domains configuration |
| iOS 13 and earlier | Not supported | Not available |
Android
On Android, Median apps render your site inside a standard WebView that supports the Service Worker API the same way Chrome does. If your Service Worker already works in a mobile browser, it will work in your Median Android app with no additional configuration.
Registration, caching, and the fetch lifecycle all behave as they would on the open web.
iOS
On iOS, Service Worker support is available only on iOS 14 or later and requires using App-Bound Domains. This feature is not supported out of the box in Median apps but can be enabled with custom implementation. Please note that the app will only communicate with the domains added in the configuration.
ImportantApple allows a maximum of 10 App-Bound Domains, and wildcards are not permitted. Each subdomain must be listed explicitly.
Enabling Service Workers on iOS with Median
- Download and build the iOS source code locally.
- Enable App-Bound Domains:
- In
LeanIOS > LEANWebViewController.m,set the following flag on line 320:config.limitsNavigationsToAppBoundDomains = YES;
- In
- Add the
WKAppBoundDomainskey to yourMedianIOS-Info.plistfile underLeanIOS > Supporting Files:<key>WKAppBoundDomains</key> <array> <string>median.co</string> <string>cdn.onesignal.com</string> <string>cdnjs.cloudflare.com</string> <string>fonts.googleapis.com</string> <string>maps.googleapis.com</string> <string>onesignal.com</string> <string>www.gstatic.com</string> </array>
For more details, refer to:
Will iOS 14 support Service Workers in WKWebView? (dev.to)
App-Bound Domains Overview (webkit.org)
If you don't have access to a macOS system to build the app, Median can handle the setup for you as part of a small custom development service. Contact us to learn more.
Updated 17 days ago