0

I'm working on an iOS app and looking to see if it is possible to know when a user opens a URL (for example, user press a button and executes code like below)

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

telprompt: show an alert when it's called. But I want a way to detect if user press Ok button or Cancel button. I need execute some code in -(void)applicationDidEnterBackground:(UIApplication *)application depending which button was pressed. Any idea?

Ravi
  • 7,929
  • 6
  • 38
  • 48
human4
  • 154
  • 2
  • 13

1 Answers1

2

You could subclass UIApplication and over-ride openURL: This will give you control and have you decide what to do. Make sure to call super implementation though if you want to open the URL

EDIT

Here is an example

How to subclass UIApplication?

Community
  • 1
  • 1
NSIntegerMax
  • 542
  • 2
  • 5
  • Thanks for your answer, it sounds interesting. But, I'm not pretty sure how implement that, but will investigate the matter. Do you have some code? – human4 Dec 21 '11 at 23:04
  • See the EDIT. I added a link. – NSIntegerMax Dec 22 '11 at 19:21
  • Thanks I'll give a look later, I am currently experimenting with **``** seems that here too there are options for my problem. – human4 Dec 22 '11 at 21:02
  • Sorry to re-open this subject but I have the same problem that human4 and I'm beginning in iOS development. I don't see how to resolve the problem by sublassing UIApplication. Do you advice to create our own dialog (with call/ cancel buttons) ? If it's this, by calling super implementation, an other dialog will appear ! If it's another kind of implementation, I don't understand what is it. Is there a way to have access to buttons created by the openURL function ? Have you an example to give us ? Thanks you per advance for your help. – Sébastien BATEZAT Jun 07 '12 at 20:12