Created
May 4, 2018 03:26
-
-
Save akdsouza/c2c4869d588c12602faee48a6f994130 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
extension AppDelegate { | |
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool { | |
guard let audioCallIntent = userActivity.interaction?.intent as? INStartAudioCallIntent else { | |
return false | |
} | |
if let contact = audioCallIntent.contacts?.first { | |
if let type = contact.personHandle?.type, type == .phoneNumber { | |
guard let callNumber = contact.personHandle?.value else { | |
return false | |
} | |
let callUrl = URL(string: "tel://\(callNumber)") | |
if UIApplication.shared.canOpenURL(callUrl!) { | |
UIApplication.shared.open(callUrl!, options: [:], completionHandler: nil) | |
} else { | |
let alertController = UIAlertController(title: nil , message: "Calling not supported", preferredStyle: .alert) | |
let okAlertAction = UIAlertAction(title: "Ok" , style: UIAlertActionStyle.default, handler:nil) | |
alertController.addAction(okAlertAction) | |
self.window?.rootViewController?.present(alertController, animated: true, completion: nil) | |
} | |
} | |
} | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment