简体   繁体   English

iOS中的拨号号码真的需要确认吗?

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

An alternative to the suitable solution already posted, you could consider using the telprompt URL scheme, eg 作为已发布的合适解决方案的替代方案,您可以考虑使用telprompt URL方案,例如

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. 如果单击某个数字,您将只在Safari中看到alertView。

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: 为了模仿safari你可以做这样的事情:

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. 另一个答案建议你可以做的一件事是使用telprompt而不是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/ 此处提供了进一步解释此代码和示例项目的类别: http//www.raizlabs.com/dev/2014/04/getting-the-best-behavior-from-phone-call-requests-using-tel -in-AN-IOS-应用程序/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM