Hubert Mane
Hubert Mane

Reputation: 13

Add function for cancel in UIAlert of Phone Call function

I have a function that places a phone call when a button is pressed.

private func callNumber(phoneNumber:String) {

  if let phoneCallURL = URL(string: "tel://\(phoneNumber)") {

    let application:UIApplication = UIApplication.shared
      if (application.canOpenURL(phoneCallURL)) {
          application.open(phoneCallURL, options: [:], completionHandler: nil)
        }
    }
}

I want to add some functionality if the users hit cancel when the alert pops up to confirm the call. How would I do that?

Upvotes: 1

Views: 515

Answers (1)

Dima
Dima

Reputation: 23634

According to this question: Prompt when trying to dial a phone number using tel:// scheme on iOS 10.3

This alert is actually a bug in iOS 10.3 and should be removed at some point in the future. It isn't supposed to come up for "tel:" links in native apps.

That said, I don't believe there is a way to detect the alert and how the user interacts with it.

Upvotes: 1

Related Questions