gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 19:37:27 24 4
gpt4 key购买 nike

IntentHandler类:

import Intents

class 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 文档说:

enter image description here

Siri 打开应用程序,但我需要显示来自 IntentUI 的 UI。如何做到这一点?

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

enter image description here

IntentViewController类:

import IntentsUI

class 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确实有可能。

enter image description here

最佳答案

虽然 Apple 说 here :

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

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

INSentMessageIntentHandling请查看INSendMessageIntentResponseCode:

public enum INSendMessageIntentResponseCode : Int {


case unspecified

case ready

case inProgress

case success

case failure

case failureRequiringAppLaunch

case failureMessageServiceNotAvailable
}

INStartWorkoutIntentResponse 用于 INStartWorkoutIntentHandling:

public enum INStartWorkoutIntentResponseCode : Int {


case unspecified

case ready

case continueInApp

case failure

case failureRequiringAppLaunch

case failureOngoingWorkout

case failureNoMatchingWorkout
}

对于第二个,只有 .continueInApp,这正是这里发生的情况,与存在的第一个相反:.success .进行中

关于ios - SiriKit,如何显示开始锻炼意图的响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41046532/

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