1

我有一个 PWA,我将用户设置保存在本地存储中,我想通过 TWA 在 Play Store 上部署这个 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 将用户设置保存在客户端。如果你能给我一个例子,我将不胜感激。

4

1 回答 1

4

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

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

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

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

此存储空间也与 Chrome 共享。

于 2019-03-05T13:57:21.197 回答