Created
May 4, 2018 03:20
-
-
Save akdsouza/bf19cd20d512ad1b8c16fcd389fd626c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Intents | |
class IntentHandler: INExtension, INStartAudioCallIntentHandling { | |
func handle(intent: INStartAudioCallIntent, completion: @escaping (INStartAudioCallIntentResponse) -> Void) { | |
let userActivity = NSUserActivity(activityType: NSStringFromClass(INStartAudioCallIntent.self)) | |
let response = INStartAudioCallIntentResponse(code: .continueInApp, userActivity: userActivity) | |
completion(response) | |
} | |
func resolveContacts(for intent: INStartAudioCallIntent, with completion: @escaping ([INPersonResolutionResult]) -> Void) { | |
var contactName: String? | |
if let contacts = intent.contacts { | |
contactName = contacts.first?.displayName | |
} | |
DataManager.sharedManager.findContact(contactName: contactName, with: { (contacts) in | |
switch contacts.count { | |
case 1: | |
completion([INPersonResolutionResult.success(with: contacts.first!)]) | |
case 2 ... Int.max: | |
completion([INPersonResolutionResult.disambiguation(with: contacts)]) | |
default: | |
completion([INPersonResolutionResult.unsupported()]) | |
} | |
}) | |
} | |
func confirm(intent: INStartAudioCallIntent, completion: @escaping (INStartAudioCallIntentResponse) -> Void) { | |
let userActivity = NSUserActivity(activityType: NSStringFromClass(INStartAudioCallIntent.self)) | |
let response = INStartAudioCallIntentResponse(code: .ready, userActivity: userActivity) | |
completion(response) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment