Skip to content

Instantly share code, notes, and snippets.

@chitu98
Created August 25, 2019 06:32
Show Gist options
  • Save chitu98/2161da0e800ac63961af79efc08fa2cf to your computer and use it in GitHub Desktop.
Save chitu98/2161da0e800ac63961af79efc08fa2cf to your computer and use it in GitHub Desktop.
func makePhoneCall(phoneNumber: String) {
if let phoneURL = NSURL(string: ("tel://" + phoneNumber)) {
let alert = UIAlertController(title: ("Call " + phoneNumber + "?"), message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Call", style: .default, handler: { (action) in
UIApplication.shared.open(phoneURL as URL, options: [:], completionHandler: nil)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment