首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SiriKit INSendMessageIntent跳过确认委托

SiriKit INSendMessageIntent跳过确认委托
EN

Stack Overflow用户
提问于 2017-08-15 07:02:47
回答 2查看 710关注 0票数 2

我已经在SiriKit上工作了一段时间,我的演示结果没有得到老板的满意。通过阅读所有的苹果文档&尽我最大努力在网上搜索,我仍然找不到一种方法来跳过SendMessageIntent中的确认步骤!

这是我的目的:

解析用户对Siri的评论后,

代码语言:javascript
复制
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"]))
    }
}

跳过这个步骤“确认”,

代码语言:javascript
复制
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)
}

直接执行句柄委托,

代码语言:javascript
复制
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)
}

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

EN

回答 2

Stack Overflow用户

发布于 2017-08-15 09:13:28

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

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

票数 0
EN

Stack Overflow用户

发布于 2019-02-17 07:12:46

@Dávid Pásztor answerd。

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

您必须删除之前的快捷方式,然后删除readd。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45687929

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档