【问题标题】:Trusted Web Activity save data locally受信任的 Web 活动在本地保存数据
【发布时间】:2019-03-05 10:43:00
【问题描述】:

我有一个 PWA,我将用户设置保存在本地存储中,我想通过 TWA 在 Play 商店中部署此 PWA。问题如下:

The host app doesn't have direct access to web content in a Trusted Web 
activity or any other kind of web state, like cookies and localStorage. 
Nevertheless, you can coordinate with the web content by passing data to and 
from the page in URLs (e.g. through query parameters, custom HTTP headers, and 
intent URIs.)

根据谷歌所说,我不明白如何在 PWA 上使用 TWA 将用户设置保存在客户端。 如果你能给我一个例子,我将不胜感激。

【问题讨论】:

    标签: local-storage progressive-web-apps trusted-web-activity


    【解决方案1】:

    使用 TWA 的应用程序由本地代码(例如:Java 或 Kotlin)和 Web 代码(HTML、CSS 和 JavaScript)组成。

    文中描述的“宿主应用程序”是对应用程序本机部分的引用,用于“启动”Web 部件,即 TWA。应用的本机部分将无法访问 localStorage。

    应用程序的Web部分(PWA),将可以正常访问localStorage、cookies等。

    换句话说,使用 localStorage 和受信任的 Web 活动的 PWA 应该按预期运行。

    此存储空间也与 Chrome 共享。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-03
      • 1970-01-01
      • 2021-12-08
      • 1970-01-01
      • 2021-06-17
      • 1970-01-01
      • 2020-06-30
      • 2020-10-26
      相关资源
      最近更新 更多