我有一个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在客户端保存用户设置。 如果您能给我一个例子,我将不胜感激。
答案 0 :(得分:2)
使用TWA的应用程序由本地代码(例如Java或Kotlin)和Web代码(HTML,CSS和JavaScript)组成。
本文中描述的“主机应用程序”是对应用程序本机部分的引用,用于“启动” Web部件TWA。该应用程序的本机部分将无法访问localStorage。
应用程序(PWA)的Web部分将可以正常访问localStorage,Cookie等。
换句话说,使用受信任的Web活动使用localStorage的PWA的行为应符合预期。
此存储空间也与Chrome共享。