Google Home app (GHA) 是用户将智能设备关联到 Google Assistant并将其分配给 Google Home Graph中的结构和房间的主要方式。 为了进行设置,用户通常需要点击多个屏幕,从可用选项列表中找到您的 Cloud-to-cloud集成。您可以帮助用户更轻松地启动设置流程,从而帮助他们更快上手,并减少用户在设置方面遇到的麻烦。
借助深层链接,您可以在应用或产品网站中嵌入深层链接,以便 用户轻松地将其 smart home 设备关联到 Assistant。点击该链接后,系统会提示用户下载 GHA(如果尚未安装),并启动 账号关联和房间分配设置流程。
Google Home 的深层链接
借助深层链接,您可以从 Android 或 iOS 应用将用户直接转到 GHA 中的特定目的地,从而简化设备设置流程。
如需直接在 GHA 中启动账号关联,请使用以下通用链接:
https://home.google.com/home-app/?deeplink=setup%2Fha_linking%3Fagent_id%3Dagent-id其中,agent-id 是云到云 集成的项目 ID,您可以在 Google Home Developer Console的项目设置下找到该 ID。
对于使用自定义协议(Android 和 iOS)启动的移动应用,您还可以使用:
googlehome://setup/ha_linking?agent_id=agent-id当用户点击通用链接时,移动平台会检查 是否存在 GHA,并打开账号关联流程。如果用户的设备上未安装 GHA,请提供 回退处理,以便将用户引导至 Google Play 或 Apple App Store,以安装或更新该应用。
Android 显式 intent
如需使用显式 intent 直接从 Android 应用触发账号关联流程,请执行以下操作:
val intent = Intent(Intent.ACTION_VIEW).apply {
val agentId = "YOUR_AGENT_ID"
data = Uri.parse("googlehome://setup/ha_linking?agent_id=$agentId")
setPackage("com.google.android.apps.chromecast.app")
}
try {
startActivity(intent)
} catch (e: ActivityNotFoundException) {
// Fallback: open Google Play app, with web browser safety
try {
val playStoreIntent = Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.google.android.apps.chromecast.app"))
startActivity(playStoreIntent)
} catch (e: ActivityNotFoundException) {
val playStoreUrl =
"https://play.google.com/store/apps/details?id=com.google.android.apps.chromecast.app"
val webIntent = Intent(Intent.ACTION_VIEW, Uri.parse(playStoreUrl))
startActivity(webIntent)
}
}
旧版深层链接
使用 madeby.google.com 或 assistant.google.com 格式化的旧版深层链接网址已废弃:
https://madeby.google.com/home-app/?deeplink=setup%2Fha_linking%3Fagent_id%3Dagent-id请更新所有应用内按钮和产品网站,以使用通用链接或 googlehome://setup/ha_linking 自定义协议。
如需详细了解如何在应用中触发深层链接,请参阅相关的 Android 文档 和 iOS 文档。