1

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?

  • Possible duplicate of [How would I create a UIAlertView in Swift?](https://stackoverflow.com/questions/24022479/how-would-i-create-a-uialertview-in-swift) – bearacuda13 Jun 30 '17 at 18:51
  • @bearacuda13 this question is completely unrelated. – Dima Jun 30 '17 at 18:55

1 Answers1

1

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.

Dima
  • 23,484
  • 6
  • 56
  • 83
  • Ah, ok. Thank you! I thought it was weird I had no control over the UIAlert but wasn't sure if maybe there was something in the documentation I missed. – Hubert Mane Jun 30 '17 at 19:08