Nermin Sehic
Nermin Sehic

Reputation: 612

How to get a callback or notification on a call or cancel action in default iOS "call" popup?

I am trying to get a callback or notification if a user clicked on a "call" or "cancel" button when trying to call a phone number from the app. I use the following code:

guard let url = URL(string: "tel://\(number)") else { return }
UIApplication.shared.open(url, options: [:]) { didCall in
  print(didCall)
}

Issue with this callback is that it is triggered when the dialog appears not when I click any of the buttons and it is always true. I couldn't find another solution. I know that since iOS 10 there's a notification I can subscribe to to get information if user clicked "Allow" or "Don't allow" notifications but similar thing doesn't seem to exist for call action.

Upvotes: 0

Views: 697

Answers (1)

Hobbes the Tige
Hobbes the Tige

Reputation: 3821

The docs state that the prompt will always appear when calling tel but since the prompt is made outside of your app, you can't do anything to observe it.

Upvotes: 1

Related Questions