Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect when user press Cancel - telprompt - objective-c

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

like image 840
Henrik Bengtsson Avatar asked Jun 12 '13 11:06

Henrik Bengtsson


1 Answers

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

like image 123
sage444 Avatar answered Nov 09 '22 04:11

sage444