1
我一直在SiriKit一段時間,我的演示結果並沒有得到我的老闆滿意。 通過閱讀所有Apple文檔&盡我所能在線搜索,我仍然無法找到一種方法來跳過SendMessageIntent中的確認步驟!SiriKit INSendMessageIntent跳過確認代理
這是我的目的:
解決用戶意見的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)
}
希望有人能爲我解答這個問題。非常感謝!
大衛你好,謝謝你的提問。 我試過你的方法來完成我的目標,但是在刪除確認功能後,我的Siri仍然確認我發送的消息。除了刪除確認功能外,有沒有我錯過的部分? –