Intents
3. Handle the shortcut (in the background in an extension)
public class ViewMagazineIntentHandler: NSObject, ViewMagazineIntentHandling {
public func confirm(intent: ViewMagazineIntent, completion: @escaping
(ViewMagazineIntentResponse) -> Void) {
completion(ViewMagazineIntentResponse(code: .ready, userActivity: nil))
}
public func handle(intent: ViewMagazineIntent, completion: @escaping
(ViewMagazineIntentResponse) -> Void) {
guard let magazine = intent.magazine else {
completion(ViewMagazineIntentResponse(code: .failure, userActivity: nil))
return
}
print("Handled magazine with identifier = \(String(describing: magazine.identifier))")
completion(ViewMagazineIntentResponse(code: .success, userActivity: nil))
}
}