PWAs on iOS 12 no longer shares Service Worker cache with Safari?

被刻印的时光 ゝ 提交于 2019-12-10 18:31:02

问题


For the PWA on iOS 11 we solved the external third party login opened in Safari by storing the login details in the service worker web cache.

This no longer works in iOS 12 (in beta as of writing). I think this must be because the PWA now has its own service worker cache that it no longer shares with Safari, but I can't confirm this.

Does anyone know if there is a way to share the service worker cache between safari and the PWA? Note that we already tried IndexedDB, but that is not shared, and of course neither are cookies.

As far as I can figure out this means that a PWA is totally sandboxed from safari and there is no way to get a third party login working. Any solutions?


回答1:


I asked Jonathan Davis(Web Technologies Evangelist for Apple) on twitter about this question. He says Web apps on iOS (“Save to home screen” apps) do not share data stores with Safari. They work as a standalone app separate from Safari and there is no way to share data between them on device.

As a possible solution that may suit you, I propose an article written by Maciej Caputa. Quoting the author the idea is to create a fake endpoint in service worker, which would save data in the cache on POST request and return cached data on GET request. Link on this article https://www.netguru.com/codestories/how-to-share-session-cookie-or-state-between-pwa-in-standalone-mode-and-safari-on-ios.

Hope this answer was helpful!




回答2:


This is no longer an issue as of iOS 12.2 (March 2019) as links of external sites now open in a PWA in-app browser and return links point back to the PWA. As a result I am now able to deploy PWA apps on iOS with third-party Auth0 login (it was already working on Android and Windows).

I learned of this from this article from Maximiliano Firtman.



来源:https://stackoverflow.com/questions/52053580/pwas-on-ios-12-no-longer-shares-service-worker-cache-with-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!