服务工作者的WKWebView模拟 [英] WKWebView analog of service worker

查看:108
本文介绍了服务工作者的WKWebView模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PWA 方法实现应用程序的一部分,该方法在 Android 上可以正常使用,但不能适用于 iOS 。我们需要

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


  • 离线内容可用性

  • 选项来动态更新内容(例如特价商品或所以)。与服务人员一起,我们会提示您更新Web内容。

如前所述此处 WKWebView 中不支持服务工作者(或 UIWebView )。那么,是否存在模拟或替代解决方案,例如智能缓存控制?

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

似乎可以存储来自应用程序的某些Web内容,并且可以在发生某些更改时对其进行更新。可能已经有一个框架/库/方法用于该目的吗?

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?

编辑
在iOS 11.3的WKWebView中不可用的服务工作者-此问题解释了WKWebView中ServiceWorkers的状态,但是没有其他选择。我想讨论任何其他解决方案。

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.

我发现的一件事是 https://github.com/xtools-at/iOS-PWA-Wrapper 。看起来是基于AppCache,但 https:// developer。 mozilla.org/zh-CN/docs/Web/HTML/Using_the_application_cache#Browser_compatibility 说,它已被弃用,建议使用SW(对于PWA则不行)。

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

推荐答案

因此,在WKWebView让服务工作者工作之前,您可以使用AppCache(尚未完全弃用)。
您可以使用并在以下位置查看源页面 https://leasingrechnen.at
他们做什么?如果浏览器中没有服务人员,他们将加载指向实现了 manifest.appcache 文件的页面的iframe,以便对该页面进行缓存。

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.

这篇关于服务工作者的WKWebView模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆