Currently, I have created a button that, when tapped, launches a phone number as a hyperlink in SwiftUI:
Button(action: {
guard let phoneNum = URL(string: "tel://1-123-456-7890") else {return}
UIApplication.shared.open(phoneNum)
}) {
Text("Call number")
}
The issue is that this, when clicked, first opens up a prompt asking "Call 1 (123) 456-7890?" with the chance to cancel. Thus, this button isn't a one click option to automatically begin a phone call.
Is there a simple way that a button, when being tapped, automatically launches a phone call after a single tap without having that prompt in between?
I was hoping that this code above would automatically launch a phone call, like what happens when you use URL in SwiftUI to open up a webpage with one tap. However, with phone numbers, there seems to be the prompt in between.
Edit: If not a simple solution, is there any solution that retains this style of having a button that launches a phone number from a string?