Detect when user press Cancel - telprompt - objective-c
Asked Answered
Z

1

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

Zlatoust answered 12/6, 2013 at 11:24 Comment(5)
Beware that the telprompt is not an official url scheme. Apple can remove this scheme in future version of iOS.Arkhangelsk
check this link.Orff
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 ;-)Zlatoust
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...Zlatoust
@HenrikBengtsson did you find any answer for your query? Please share. Thanks.Absorb
N
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

Norton answered 11/3, 2014 at 20:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.