Service Workers
Service Workers are the modern standard for enabling offline functionality on the web. If your website uses Service Workers to support offline access, that same setup will also work in your Median app - subject to platform-specific limitations. Previously, both Android and iOS platforms supported HTML5 Cache Manifest. However, this is now deprecated on iOS so it will only work on Android.
Android Support
On Android, Service Workers should work out of the box in Median apps. No additional configuration is required.
iOS Support
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.
Important
Apple allows a maximum of 10 App-Bound Domains, and wildcards are not permitted. Each subdomain must be listed explicitly.
To enable Service Workers on iOS:
- 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
WKAppBoundDomains
key to yourMedianIOS-Info.plist
file 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 about 1 month ago