Google 上的操作检查可用手机 phone

Actions on Google check for available mobile phone

我目前正在使用 google SDK 上的动作创建多表面动作。在此操作中,我的用户需要输入代码,如果他们输入代码 3 次失败,我想检查用户是否有可用的手机 phone,以便他们可以通过 phone 输入代码键盘。

我已经试过 surface capabilities, but I noticed that there isn't a check for a specific device category. Instead the check is done based on capabilities

我想要实现的是,如果用户无法通过语音输入代码,如果他们使用的设备没有键盘(Google Home 或 Google Nest Hub)并且他们有可用的手机 phone,系统会提示他们将对话转移到他们的移动设备上。

我目前使用以下代码来确定用户是否拥有移动设备并且尚未使用移动设备:

    const hasOtherDeviceWithScreen = conv.available.surfaces.capabilities.has("actions.capability.SCREEN_OUTPUT");
    const hasOtherDeviceWithBrowser = conv.available.surfaces.capabilities.has("actions.capability.WEB_BROWSER");

    const hasAvailableMobileDevice = (hasOtherDeviceWithScreen === true && hasOtherDeviceWithBrowser === true);
    const currentDeviceHasScreen = conv.screen;
    const currentDeviceHasBrowser = conv.surface.capabilities.has("actions.capability.WEB_BROWSER");

    const handOverAvailable = (hasAvailableMobileDevice === true && currentDeviceHasBrowser === false);

我知道切换只能用 IOS & Android phones 完成,所以检查屏幕 + 互联网应该检测到 phone,但我如果有超过 1 个其他设备可用,我不确定它是如何工作的。

检查屏幕设备和浏览器设备是否保证用户只有一台设备具有这些功能,或者当用户有多个设备时是否可能 returns 为真?

conv.surface.capabilities 是特定设备的所有功能的数组,而 conv.available.surfaces.capabilities 是用户在所有设备上的所有功能的数组。

当您从智能扬声器之类的东西过渡到 phone 之类的东西时,您会在每个有效表面上收到通知。基本上,你的 phone.

检查 Web 浏览器和屏幕通常应该与移动设备相匹配,尽管功能框架是专门设计的,因此您不需要进行直接的设备类型检查。