ios – SiriKit,如何显示开始锻炼意图的响应?

ios – SiriKit,如何显示开始锻炼意图的响应?,第1张

概述IntentHandler类: import Intentsclass IntentHandler: INExtension, INStartWorkoutIntentHandling { public func handle(startWorkout intent: INStartWorkoutIntent, completion: @escaping (INStartWorkou IntentHandler类:

import Intentsclass IntentHandler: INExtension,INStartWorkoutIntentHandling {    public func handle(startWorkout intent: INStartWorkoutIntent,completion: @escaPing (INStartWorkoutIntentResponse) -> VoID) {        let userActivity = NSUserActivity(activityType: NsstringFromClass(INStartWorkoutIntent.self))        let response = INStartWorkoutIntentResponse(code: .continueInApp,userActivity: userActivity)        completion(response)    }    //MARK: - INStartWorkoutIntentHandling    func confirm(startWorkout intent: INStartWorkoutIntent,completion: @escaPing (INStartWorkoutIntentResponse) -> VoID) {        completion(INStartWorkoutIntentResponse(code: .continueInApp,userActivity: nil))    }}

Apple文档说:

Siri打开应用程序,但我需要显示IntentUI的UI.这该怎么做?

换句话说:如何准备显示响应,加载意图UI扩展,准备界面并在代码中显示它?

IntentVIEwController类:

import IntentsUIclass IntentVIEwController: UIVIEwController,INUIHostedVIEwControlling {    //MARK: - INUIHostedVIEwControlling    func configure(with interaction: INInteraction!,context: INUIHostedVIEwContext,completion: ((CGSize) -> VoID)!) {        if let completion = completion {            completion(self.desiredSize)        }    }    var desiredSize: CGSize {        return self.extensionContext!.hostedVIEwMaximumAllowedSize    }}

基于this教程,它确实可能.

解决方法 虽然Apple说 here:

You can provIDe an Intents UI extension if you are supporting intents in the following domains:
Messaging
Payments
RIDe booking
Workouts

我认为这是不可能的,因为负责开放UI的响应没有为此做好准备:

请查看INSENTMessageIntentResponseCode以了解INSENTMessageIntentHandling:

public enum INSendMessageIntentResponseCode : Int {    case unspecifIEd    case ready    case inProgress    case success    case failure    case failureRequiringAppLaunch    case failureMessageServiceNotAvailable}

INStartWorkoutIntentHandling的INStartWorkoutIntentResponse和INStartWorkoutIntentResponse:

public enum INStartWorkoutIntentResponseCode : Int {    case unspecifIEd    case ready    case continueInApp    case failure    case failureRequiringAppLaunch    case failureOngoingWorkout    case failureNoMatchingWorkout}

对于第二个,只有.continueInApp,这正是这里发生的,与存在的第一个相反:.success和.inProgress

总结

以上是内存溢出为你收集整理的ios – SiriKit,如何显示开始锻炼意图的响应?全部内容,希望文章能够帮你解决ios – SiriKit,如何显示开始锻炼意图的响应?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1002311.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存