问题描述
我添加了一个INUIAddVoiceShortcutButton
,它可以正常工作,但是当我删除快捷方式应用程序时,它将停止工作。代表仍然返回快捷方式成功,但是按钮没有更改以反映添加了快捷方式。我发现必须重新安装“快捷方式”应用程序并重新启动手机才能返回功能。
是否可以确定是否已安装Ahortcuts应用程序?缺少什么吗?
我还使用Apple的演示Soup Chef应用程序对此进行了测试。
解决方法
我发现最好的方法是致电INVoiceShortcutCenter.shared.getAllVoiceShortcuts
返回错误:
Optional(
Error Domain=IntentsErrorDomain
Code=7001 "Failed to get voice shortcuts"
UserInfo={
NSDebugDescription=Failed to get voice shortcuts,NSUnderlyingError=0x283c42910
{
Error Domain=VCVoiceShortcutsErrorDomain
Code=1004
"Shortcuts app is not installed"
UserInfo={NSLocalizedFailureReason=Shortcuts app is not installed
}
}}
)
添加快捷方式后,它返回nil:
func addVoiceShortcutViewController(_ controller: INUIAddVoiceShortcutViewController,didFinishWith voiceShortcut: INVoiceShortcut?,error: Error?) {
INVoiceShortcutCenter.shared.getVoiceShortcut(with: voiceShortcut!.identifier) { (shortcut,error) in
print("\(String(describing: shortcut))") // nil
print("\(error.debugDescription)") // nil
}
}