我已按照以下教程中的说明创建了Siri Intent:link to the tutorial
我添加了一个带有单个参数的意图。我没有捐赠意图。在“设置”的“ Siri快捷方式”页面中看不到意图。
在Siri设置中可见之前是否应该捐赠意图?
在我的应用程序中,余额始终显示在主页上,因此我应该在用户每次查看主页时捐赠快捷方式吗?是否可以将快捷方式指定为“可用”,以便在安装应用程序后将其自动添加到设置中?
答案 0 :(得分:1)
您可以建议快捷方式,尽管用户没有在应用程序中执行特定操作,否则可能会导致捐赠。 为此,您必须创建对用户来说可能很有趣的建议,并将其提供给 INVoiceShorcutCenter 。
以下代码可能会帮助您:
var suggestions : [INShortcut] = []
let intent = CustomIntent()
intent.name = "Suggested Shortcut"
if let image = UIImage(named: "intenticon"), let data = image.pngData() {
intent.setImage(INImage(imageData: data), forParameterNamed:\CustomIntent.name)
}
intent.suggestedInvocationPhrase = "Show the name"
if let shortcut = INShortcut(intent: intent) {
suggestions.append(shortcut)
}
// Suggest the shortcuts
INVoiceShortcutCenter.shared.setShortcutSuggestions(suggestions)
要删除所有建议,您只需建议一个空的 INShortcut 数组。