Marco Dinatsoli Marco Dinatsoli - 8 months ago 43
iOS Question

where is wrong in my function to make a call

this is my code to make a phone call

let phoneCall = phoneNumberTF.text
if let phoneCall = phoneCall {
let url = NSURL(string: "tel://\(phoneCall)")

}else {
let alert = UIAlertController(title: "Error", message: "not correct phone", preferredStyle: .Alert)
let action = UIAlertAction(title: "Retry", style: .Default, handler: nil)

I'm getting this error in the log

ERROR: There is no registered handler for URL scheme tel

hint: I already check this question, but the solution didn't work with me
Calling a phone number in swift


the correct url scheme is something like tel:PHONE_NUMBER (without the slashes you included). you should also check if the application CAN open the url you provide by calling UIApplication.sharedApplication.canOpenURL()...

let phoneNumber = "123-456-789"
let phoneURL = NSURL(string: "tel:\(phoneNumber)")!
if UIApplication.sharedApplication().canOpenURL(phoneURL) {