I know there is a built-in template for it.
Go to the File menu and choose New> Target
Select iOS> Application Extensions from the left pane.
Now select the Intents extension.
This will create two new groups: YourExtension and YourExtensionUI. If you open the YoureExtension group, you will see IntentHandler.swift, which contains sample code for handling workouts.
Here you can find a simpler example:
class IntentHandler: INExtension, INSendMessageIntentHandling {
override func handler(for intent: INIntent) -> AnyObject {
return self
}
func handle(sendMessage intent: INSendMessageIntent, completion: (INSendMessageIntentResponse) -> Void) {
print("Send message: " + (intent.content ?? "No message"))
let response = INSendMessageIntentResponse(code: .success, userActivity: nil)
completion(response)
}
}
I did it, everything is fine.
Now my problem is to use INStart Workout Intent instead of INSendMessageIntent, how should I? Is there a built-in template for this purpose?