我已经在SiriKit上工作了一段时间,我的演示结果没有得到老板的满意。通过阅读所有的苹果文档&尽我最大努力在网上搜索,我仍然找不到一种方法来跳过SendMessageIntent中的确认步骤!
这是我的目的:
解析用户对Siri的评论后,
func resolveContent(forSendMessage intent: INSendMessageIntent, with completion: @escaping (INStringResolutionResult) -> Void) {
if let text = intent.content, !text.isEmpty {
if text == "Login with Touch ID" {
completion(INStringResolutionResult.success(with: text))
} else if text == "Change password"{
completion(INStringResolutionResult.success(with: text))
}
completion(INStringResolutionResult.disambiguation(with: ["Login with Touch ID", "Change password"]))
} else {
completion(INStringResolutionResult.disambiguation(with: ["Login with Touch ID", "Change password"]))
}
}跳过这个步骤“确认”,
func confirm(sendMessage intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) {
// Verify user is authenticated and your app is ready to send a message.
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self))
let response = INSendMessageIntentResponse(code: .success, userActivity: userActivity)
completion(response)
}直接执行句柄委托,
func handle(sendMessage intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) {
// Implement your application logic to send a message here.
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self))
let response = INSendMessageIntentResponse(code: .success, userActivity: userActivity)
completion(response)
}希望有人能帮我回答这个问题。非常感谢!
发布于 2017-08-15 09:13:28
confirm函数是可选的,您不需要实现它才能符合INSendMessageIntentHandling协议,只需要handle(intent:completion:)。这表明您可以跳过确认部分。
您应该删除confirm函数,SiriKit将直接调用您的handle函数,而不需要确认。
发布于 2019-02-17 07:12:46
@Dávid Pásztor answerd。
不要实现confirm函数。不要在User confirmation required中签入YourXX.intentdefination
您必须删除之前的快捷方式,然后删除readd。
https://stackoverflow.com/questions/45687929
复制相似问题