gpt4 book ai didi

ios - SiriKit INSendMessageIntent 跳过确认委托(delegate)

转载 作者:行者123 更新时间:2023-11-28 08:04:05 25 4
gpt4 key购买 nike

我已经在 SiriKit 上工作了一段时间,我的演示结果让我的老板不满意。通过阅读所有 Apple 文档并尽力在线搜索,我仍然找不到跳过 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)
}

并直接处理委托(delegate),

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)
}

希望有人能帮我回答这个问题。非常感谢!

最佳答案

confirm 函数是可选的,你不需要实现它就能够符合INSendMessageIntentHandling 协议(protocol),只有handle(intent:完成:) 是必需的。这表明您可以跳过确认部分。

您只需删除confirm 函数,SiriKit 将直接调用您的handle 函数,无需确认。

关于ios - SiriKit INSendMessageIntent 跳过确认委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45687929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com