我正在SiriKit
为我们的应用程序开发意图扩展。我们正在使用锻炼扩展类型。问题是,我只是将所需的方法放入并始终通过.ready
,但 Siri 总是响应,
抱歉,您必须在应用程序中继续。
我也尝试过其他回复(.failure
和.unspecified
),但她仍然说要继续使用应用程序。我已经按照 Apple 提供的文档来设置我的.plist
文件,但它仍然可能与此相关。
这是我的意图代码:
class IntentHandler: INExtension, INStartWorkoutIntentHandling, INPauseWorkoutIntentHandling, INResumeWorkoutIntentHandling, INCancelWorkoutIntentHandling, INEndWorkoutIntentHandling {
override func handler(for intent: INIntent) -> Any {
// This is the default implementation. If you want different objects to handle different intents,
// you can override this and return the handler you want for that particular intent.
return self
}
func handle(startWorkout intent: INStartWorkoutIntent, completion: @escaping (INStartWorkoutIntentResponse) -> Void) {
print("Starting Service")
let activity = NSUserActivity(activityType: "start_service")
let result = INStartWorkoutIntentResponse(code: .ready, userActivity: activity)
completion(result)
}
func handle(endWorkout intent: INEndWorkoutIntent, completion: @escaping (INEndWorkoutIntentResponse) -> Void) {
print("Ending Service")
let result = INEndWorkoutIntentResponse(code: .ready, userActivity: nil)
completion(result)
}
func handle(pauseWorkout intent: INPauseWorkoutIntent, completion: @escaping (INPauseWorkoutIntentResponse) -> Void) {
print("Pausing Service")
let result = INPauseWorkoutIntentResponse(code: .ready, userActivity: nil)
completion(result)
}
func handle(cancelWorkout intent: INCancelWorkoutIntent, completion: @escaping (INCancelWorkoutIntentResponse) -> Void) {
print("Cancel Service")
let result = INCancelWorkoutIntentResponse(code: .ready, userActivity: nil)
completion(result)
}
func handle(resumeWorkout intent: INResumeWorkoutIntent, completion: @escaping (INResumeWorkoutIntentResponse) -> Void) {
print("Resume Service")
let result = INResumeWorkoutIntentResponse(code: .ready, userActivity: nil)
completion(result)
}
}
我尝试了一个处理开始锻炼意图的断点,它确实达到了该功能。我还尝试传递.ready
给 INMessageIntent,Siri 没有在应用程序中说打开就做出了回应。我想知道锻炼扩展是否总是如此。如果是,我仍然希望 Siri 显示我的 IntentsUI。
感谢您的回复。