如何从谷歌家庭设备获取用户位置

时间:2018-03-10 15:14:46

标签: actions-on-google dialogflow google-home jovo-framework

如何实现此示例:

      let device = this.googleAction().getRequest().getDevice();
      console.log(device);
      this.tell('Thanks for your precise location');

https://raw.githubusercontent.com/jovotech/jovo-framework-nodejs/master/examples/google_action_specific/appAskForPermission.js

1 个答案:

答案 0 :(得分:0)

您是否首先要求“精确定位”,如您所链接的示例所示?

this.googleAction().askForPreciseLocation('Precise Location pre text');

如果用户授予您权限,则会跳转到“ON_PERMISSION”处理程序,您可以在其中访问信息,如下所示:

 if (requestUser.permissions.indexOf('DEVICE_PRECISE_LOCATION') > -1) {
        let device = this.googleAction().getRequest().getDevice();
        console.log(device);
        this.tell('Thanks for your precise location');
    }

您可以在Jovo文档中找到更多信息:Google Assistant > Data > ON_PERMISSION