【发布时间】:2019-12-06 16:48:44
【问题描述】:
所以我一直在关注 Google 提供的这份文档: https://developers.google.com/actions/identity/user-info
最近,request.userId 已被 Google 弃用。所以我转向这个文档,它指定使用 conv.user.storage。
我曾尝试在我的应用中使用 storage 属性,但它似乎没有存储任何用户数据,因为下次我访问它时,存储会生成一个新的用户 ID 密钥。
const data = "Something you want to save";
let userId;
// if a value for userID exists in user storage, it's a returning user so we can
// just read the value and use it. If a value for userId does not exist in user storage,
// it's a new user, so we need to generate a new ID and save it in user storage.
if ('userId' in conv.user.storage) {
userId = conv.user.storage.userId;
} else {
// generateUUID is your function to generate ids.
userId = generateUUID();
conv.user.storage.userId = userId
}
上面是我试过的代码的 sn-p。我显然已经用我自己的函数替换了 generateUUID() 函数,并且它每次都会生成一个随机用户 ID。问题是我永远无法在 conv.user.storage 中找到“userId”。
我还进入了我的 Google Home 应用,查看了“[查看用户存储]”,但它什么也没有。
【问题讨论】:
标签: actions-on-google google-home google-account google-assist-api account-linking