Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dial number in iOS really need confirmation?

I am using the following code to dial number and testing with my device. It seems no confirmation is needed, correct?

NSURL *url = [NSURL URLWithString:@"tel://12345678"];
[[UIApplication sharedApplication] openURL:url];
like image 802
Howard Avatar asked May 09 '11 07:05

Howard


2 Answers

An alternative to the suitable solution already posted, you could consider using the telprompt URL scheme, e.g.

NSURL *url = [NSURL URLWithString@"telprompt://12345678"];
[[UIApplication sharedApplication] openURL:url];
like image 141
Sedate Alien Avatar answered Oct 05 '22 07:10

Sedate Alien


Confirmation isn't required and isn't shown when done programmatically. You will only see the alertView in Safari if a number is clicked.

However, in my own experience, I believe it's more convenient for the customer to see a dialog box so they don't accidentally call someone. People just tap things in apps without even thinking and that could be bad in this case.

To mimic what safari does you can do something like this:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Call 12345678?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Call", nil];
[alert show];
alert.tag = 1;
[alert release];

and

-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    switch (alertView.tag) {
        case 1:
            if (buttonIndex == 1) {
                NSURL *url = [NSURL URLWithString:@"tel://12345678"];
                [[UIApplication sharedApplication] openURL:url];
            }
            break;
        default:
            break;
    }
}
like image 35
shabbirv Avatar answered Oct 05 '22 06:10

shabbirv