9

I'm trying to implement part of app with PWA approach, that works fine on Android, but not for iOS. We need to have

  • offline content availability
  • option to update content dynamically (like special offers or so). With service worker we show prompt to update web content.

As were mentioned here service workers are not supported within WKWebView (or UIWebView). So is there analog or alternative solution like smart cache control?

Seems like it is possible to store some web content from app and be able to update it if something changes. May there is already a framework/library/approach for that purpose?

EDIT Service Workers unavailable in WKWebView in iOS 11.3 - this question explains the status of ServiceWorkers in WKWebView, but no alternative is given. I would like to discuss any alternative solutions.

One thing I discovered is https://github.com/xtools-at/iOS-PWA-Wrapper. It looks like working based on AppCache, but https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache#Browser_compatibility says it is deprecated and adviced to use SW instead (which is not an option for PWA).

SimB4
  • 162
  • 1
  • 9
  • 2
    How about, trying the solutions listed in this [SO post (Service workers and iOS / Safari)](https://stackoverflow.com/questions/29895387/service-workers-and-ios-safari)? – MαπμQμαπkγVπ.0 Mar 13 '19 at 08:47
  • @MαπμQμαπkγVπ.0 Thanks for reply, the link you gave tells it works on Safari (same in the link I posted above). But I didn't find any solution for WebView so far. – SimB4 Mar 15 '19 at 11:20
  • See here for a solution: https://stackoverflow.com/questions/49673399/service-workers-unavailable-in-wkwebview-in-ios-11-3/64155509#64155509 – Silicium Oct 01 '20 at 13:20

1 Answers1

3

So before WKWebView get service-workers to work, you can use AppCache (not yet fully deprecated). You can use this and take a look at source page at https://leasingrechnen.at What they do? In case if there is no service worker in browser, they load iframe that points to a page with manifest.appcache file implemented, so the page is cached.

SimB4
  • 162
  • 1
  • 9
  • As of iOS 15 AppCache is disabled for WKWebView. See: https://bugs.webkit.org/attachment.cgi?id=426150&action=diff – h3dkandi Jan 18 '22 at 14:21