android - Google Actions 的 Intent 名称无效
问题描述
我正在努力在我的应用中添加 Google 助理操作。运行 App Actions 测试工具时,不断弹出以下错误,我不知道该怎么办。
App Actions Test Tool v3.1.5
Preview Creation Error
Status Code: 400
Message: Precondition check failed.
- Invalid intent name 'actions.intent.CHANGE_MY_SHIPMENT_DATE_BY_DATE'
- Invalid intent name 'actions.intent.CHANGE_MY_SHIPMENT_DATE_BY_DURATION'
- Invalid intent name 'actions.intent.CHANGE_MY_FREQUENCY'
- Invalid intent name 'actions.intent.ADD_FLOW'
- Invalid intent name 'actions.intent.ADD_TO_SUBSCRIPTION'
- Invalid intent name 'actions.intent.REMOVE_FLOW'
- Invalid intent name 'actions.intent.SNOOZE'
- Invalid intent name 'actions.intent.CUSTOMER_SERVICE'
- A parameter mapping is missing for the URL parameter 'box' in URL template 'content://com.xxyz.app.slices.provider/remove_flow{?product,box}' for intent 'actions.intent.REMOVE_FLOW'
动作.xml
<actions>
<action intentName="actions.intent.CHANGE_MY_SHIPMENT_DATE_BY_DATE">
<fulfillment
fulfillmentMode="actions.fulfillment.SLICE"
urlTemplate="content://com.xyz.app.slices.provider/change_shipment_by_date{?datetime}">
<parameter-mapping
intentParameter="datetimeType"
required="false"
urlParameter="datetime" />
</fulfillment>
</action>
...
<action intentName="actions.intent.CUSTOMER_SERVICE">
<fulfillment urlTemplate="https://xyz-app.firebaseapp.com/customer_service"/>
</action>
</actions>
我已经按照谷歌提供的健身应用程序为例,但它失败了。
我已经生成了一个aab文件并上传到了发布管理的内部渠道。我已经有一个生产应用程序,并且我为这个新应用程序保留了相同的 pkg 名称。
此外,我在 DialogFlow 和 Actions 控制台中添加了这些意图。在云上进行测试以及在我的设备上使用 Google 助理时,该流程正在运行。GA 识别对话流,但应用程序中没有发生任何事情。没有切片或深层链接。我添加了日志,但没有任何日志显示。只有下面的 init 有效:
@RequiresApi(Build.VERSION_CODES.P)
private fun grantAssistantPermissions() {
Timber.e(" [VOICEASSISTANT] grantAssistantPermissions")
getAssistantPackage()?.let { assistantPackage ->
val sliceProviderUri = Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(SLICE_AUTHORITY)
.build()
SliceManager.getInstance(this).grantSlicePermission(assistantPackage, sliceProviderUri)
}
}
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
private fun getAssistantPackage(): String? {
val resolveInfoList = packageManager?.queryIntentServices(
Intent(VoiceInteractionService.SERVICE_INTERFACE), 0
)
return resolveInfoList?.firstOrNull()?.serviceInfo?.packageName
}
我的清单包含:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.app.slice.category.SLICE" />
</intent-filter>
</provider>
...
<!-- Define your supported deeplinks -->
<intent-filter
android:autoVerify="true"
tools:targetApi="m">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="xyz-app.firebaseapp.com"
android:scheme="https" />
</intent-filter>
<!-- Required to support search action intents from Google Search -->
<intent-filter>
<action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
知道为什么它一直抱怨不良意图名称,甚至对我提出的任何行动都没有反应吗?
我不知道应用程序是否收到了这些操作。我被期望有一个意图,但没有。由于操作工具已经引发错误,我认为我不能期望 actions.xml 能按预期工作
谢谢你的帮助
解决方案
App Actions 和 slice 仅适用于 App Actions 可用的内置 Intent。它们不适用于自定义对话操作或使用 Dialogflow 构建的对话操作。
推荐阅读
- bloomberg - 在 Excel 上使用 Bloomberg API 查找股票代码更改/收购
- java - 如何从框架的左侧制作一条垂直的按钮?
- java - How to DRY inside activities
- django - What would be considered the root directory to a third party javascript in Django
- spring-boot - 使用 Spring Security 授权使用 OAuth2 数据创建自定义用户
- reactjs - How to Pass Variables from a ReactJS application to REST API
- php - php mysqli_connect 连接错误(0 尝试使用 MAMP 连接到 localhost 数据库
- c# - 具有多个客户端的异步服务器套接字
- swift - Patterns: Singletons vs. Static vars and methods approach
- macos - 未安装内核驱动程序 (rc=-1908) Mac High Sierra 10.13