【问题标题】:SiriKit INSendMessageIntent skip confirm delegateSiriKit INSendMessageIntent 跳过确认委托
【发布时间】:2017-08-15 07:02:47
【问题描述】:

我已经在 SiriKit 上工作了一段时间,我的演示结果并不让我的老板满意。 通过阅读所有Apple文档并尽力在线搜索,我仍然找不到跳过SendMessageIntent中确认步骤的方法!


这是我的目的:

将用户cmets解析为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)
}

并且直接做handle 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)
}

希望有人可以为我回答这个问题。非常感谢!

【问题讨论】:

    标签: ios swift message sendmessage sirikit


    【解决方案1】:

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

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

    【讨论】:

    • 大卫您好,感谢您的提问。我已经尝试过你的方法来实现我的目标,但是在删除确认功能后,我的 Siri 仍然确认我发送的消息。除了删除确认功能,我还有什么遗漏的吗?
    【解决方案2】:

    正如@Dávid Pásztor 回答的那样。

    不要实现confirm 函数。 不要在 YourXX.intentdefination 中检查 User confirmation required

    而且你必须先删除之前的快捷方式,然后再读取。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-21
      • 2013-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-26
      • 1970-01-01
      • 2023-03-11
      相关资源
      最近更新 更多