9

I have seen this question before but without any real answer.

I am using the following code to start a phone call in objective-c.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt:1234567890"]]

This code opens a dialog with the telephone number, an Abort button and a Call button.

Does anyone know how to detect if the Cancel button was pressed?

I need to do some special arrangements in app if Cancel is pressed.

I have tried to use a UIAlertView combined with the @"tel:1234567890" command, but that isn't any good. If the "tel:" command is used, the user will leave the app which isn't what I want...

Thanks!

/Henrik

Praveen S
  • 10,355
  • 2
  • 43
  • 69
Henrik Bengtsson
  • 344
  • 4
  • 17
  • 4
    Beware that the `telprompt` is not an official url scheme. Apple can remove this scheme in future version of iOS. – rckoenes Jun 12 '13 at 11:30
  • check this [link](http://stackoverflow.com/questions/13743344/how-to-find-out-if-user-pressed-call-or-cancel-button-when-making-call-from-my-a). – Mudit Bajpai Jun 12 '13 at 11:55
  • rckoenes - I am aware that the telprompt isn't an official scheme. However, I have seen posts within this topic that says that their apps have been approved by Apple so I hope that they are right ;-) – Henrik Bengtsson Jun 12 '13 at 12:10
  • Mudit Bajpai - I looked at that post before. It gives a hint when the user completes the call, not when he Cancels it if I am not mistaken. I tried it a while ago... – Henrik Bengtsson Jun 12 '13 at 12:11
  • @HenrikBengtsson did you find any answer for your query? Please share. Thanks. – Zeeshan Feb 08 '16 at 10:33

1 Answers1

3

I think is possible to make guess which button user selected in call prompt.

After you call openURL: your app receive [AppDelegate applicationWillResignActive:] method call.

Then possible two cases:

If user select Call you get [AppDelegate applicationDidEnterBackground:] because phone app will open.

If user select Cancel you get [AppDelegate applicationDidBecomeActive:] method call.

I think you can implement some singleton to save app state and update it in this methods.

Good luck

sage444
  • 5,661
  • 4
  • 33
  • 60