Hello I've button action for call number , but when I used it don't call and nothing shows.
My codes under below.
@IBAction func callPhone(sender: AnyObject) {
UIApplication.shared().canOpenURL((NSURL(string: "tel://1234567890")! as URL))
}
Thank You !
Proper Swift 3.0 Code
if let url = URL(string: "tel://\(phoneNumber)") {
UIApplication.shared().open(url, options: [:], completionHandler: nil)
}
In Swift 3.0 NSURL
have changed to URL
. And sharedApplciation
changed to shared
. Also OpenURL
changed to open
, they have added a bunch other parameters to the open
method, you can pass empty dictionary in options
and nil
in the completionHandler
.