I want to intent a call , this is my code :
if let urlMobile = NSURL(string: "tel://076938483"), UIApplication.shared.canOpenURL(urlMobile as URL) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(urlMobile as URL, options: [:], completionHandler: nil)
}
else {
UIApplication.shared.openURL(urlMobile as URL)
}
}
I'm using swift 3 to do so but I get this error:
-canOpenURL: failed for URL: "tel://09178883828" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
any idea to do so ?
Your code works perfectly fine. Run it on an actual device if your using Simulator. You can't simulate a call on a Mac/MacBook.
Please have a look at Simulator Hardware Actions in Apple documentation.
Some LSApplicationQueriesScheme do not work on Simulator. Error Code -10814 is for kLSApplicationNotFoundErr. Simulator can't launch Dial Pad for Telephone. So run it on iPhone device.
This worked for me!!!
Code Should be
if let url = NSURL(string: "tel://\(yourNumber)"), UIApplication.shared.canOpenURL(url as URL) {
UIApplication.shared.open(url as URL, options: [:], completionHandler: nil)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With