iOS Make a call from String
You can use a simple function below to make a call from your iOS app.
//MARK:- String
extension String {
//MARK: makeACall
func makeACall() {
guard let url = URL(string: "tel://\(self)"), UIApplication.shared.canOpenURL(url) else { return }
if #available(iOS 10, *) {
UIApplication.shared.open(url)
} else {
UIApplication.shared.openURL(url)
}
}
}
You can call from anywhere like
It will fail to run in some cases like below example
Make sure that, your phone number should be in numeric format.
Note:
To get the result, run the app on a real device because it won't work on the simulator
Let's grow together 🌱
Cheers 🍻