Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akdsouza/c2c4869d588c12602faee48a6f994130 to your computer and use it in GitHub Desktop.
Save akdsouza/c2c4869d588c12602faee48a6f994130 to your computer and use it in GitHub Desktop.
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