I want to validate if user tapped on Call button or Cancel button after telprompt

Current code:

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@", [personDetails valueForKey:@"phone"]]];
    [[UIApplication  sharedApplication] openURL:url];

How can I do so?

有帮助吗?

解决方案 2

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(called:) name:@"UIApplicationSuspendedNotification" object:nil];

-(void)called:(NSNotification *) notification
{
    NSLog(@"Tapped Call button");
}

if Call button was tapped then application will be terminated and go into background so just add an observer for the UIApplicationSuspendedNotification notification.

其他提示

First telprompt: is not a documented URL schema and should not be used. Since Apple can change the way it used at any moment.

Second since data is passed back to your app, you will not be able to detect a if call was made. You might be able to detect if you use the CoreTelephony. But getting this to work require your app to run in the background and you might have to misuse some background mode for this which will make Apple reject your app.

Can you explain why you want to detect if there was a call made?

For my case, I used tel:// instead of using telprompt:// and make my own UIAlertView. This way you could detect if the call option is tapped from the UIAlertView's delegate.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top