1

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?

pulsetime
  • 111
  • 2
  • 3
    No, the purpose of the prompt is to let the user know that they are about to make a call and give them an opportunity to cancel. What would be the point of Apple creating such a prompt if it could be avoided? – Paulw11 Aug 19 '23 at 03:19
  • 1
    It wasn't this way all time. Only in iOS 10.3 and later, the URL"tel://" displays an alert and requires user confirmation. There is no option to configure this behaviour. – CouchDeveloper Aug 19 '23 at 10:13

0 Answers0