Siri always responds 'Continue in the app' when starting workout with SiriKit

别说谁变了你拦得住时间么 提交于 2019-12-04 19:12:23

Once you are ready to start the workout in your app, you need to call the completion handler with .continueInApp

So that would be something like:

public func handle(startWorkout intent: INStartWorkoutIntent, completion: @escaping (INStartWorkoutIntentResponse) -> Swift.Void) {
    let userActivity = NSUserActivity(activityType: NSStringFromClass(INStartWorkoutIntent.self))
    let response = INStartWorkoutIntentResponse(code: .continueInApp, userActivity: userActivity)
    completion(response)
}

See the documentation:

Your extension is ready to transfer control to the app so that the workout can be started. Upon returning this code, SiriKit launches your app and passes it the NSUserActivity object you provided at initialization time. (If you did not provide a user activity object, SiriKit creates one for you.) SiriKit adds an INInteraction object with the intent and your response to the user activity object before delivering it. Your app should use the information in the user activity object to start the workout.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!