开发者

Dial number in iOS really need confirmation?

开发者 https://www.devze.com 2023-03-04 23:49 出处:网络
I am using the following code to dial number and testing with my device. It seems no confirmation is needed, correct?

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 sharedA开发者_如何学Pythonpplication] openURL:url];


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];


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;
    }
}


Confirmation isn't required but it's desirable as it prevents confusion when users are dropped into the dialing application. one thing that you can do that was suggested by another answer is to use telprompt rather then just tel. This will provide the prompt that's necessary via a simple dialog. It also has a very nice side-effect of dropping users back into the calling application after the phone call is complete. This key elements allows you to keep going rather then getting kicked out of your app.

A category that further explains this code and a sample project is available here: http://www.raizlabs.com/dev/2014/04/getting-the-best-behavior-from-phone-call-requests-using-tel-in-an-ios-app/

0

精彩评论

暂无评论...
验证码 换一张
取 消