1
在Actions on Google site我找得到的用户ID,以确定整个对话和设备的用户的功能。在docs section under getUser我读以下:获取在操作的用户ID在谷歌
的getUser()返回用户
获取用户对象。用户对象包含有关 用户信息,包括一个字符串标识符和个人信息(需要 请求权限,请参阅askForPermissions)。
所以首先需要申请许可。为此,我按照链接。但是,我发现只有三个可以请求的权限。
- NAME
- DEVICE_COARSE_LOCATION
- DEVICE_PRECISE_LOCATION
世界上没有获授的用户ID的权限。当我运行我的代码并尝试获取用户ID时,它返回undefined。获取用户名正常工作。
function requestPermissonsIntent(app){
const permission = [app.SupportedPermissions.NAME];
app.askForPermission('Für eine korrekte Ausführung', permission);
}
//later in my code when asking for the userID and userName
if(app.isPermissionGranted()){
const userName = app.getUserName().displayName;
//getting the userName works fine
const userUID = app.getUser().userID;
//userUID is undefinded
...
如何获取用户ID?
可耻的是我。有时它很容易。我曾多次阅读我的代码,但没有发现这个错误。所以现在我得到了userId我更新了我的问题。有没有办法记住用户授予该权限? –
这确实是一个单独的问题。继续,并把它作为一个新的SO问题,我们很乐意回答。 – Prisoner
(小写字母-d很容易被忽略,我自己也做过很多次了。) – Prisoner