SCENARIO
我有一个UIWebView
的应用,我制作了一些覆盖要求的网址。
问题
要使url
tel:
打开iOS7
,iOS8
和[[UIApplication sharedApplication] openURL:request.URL];
的工作很奇怪,它会在后台直接拨打电话,但它也要求确认,所以用户体验太可怕了:
telprompt
解
为了解决这个问题,我使用了iOS
。它适用于所有NSURL *url = [NSURL URLWithString:@"telprompt://637****"];
return [[UIApplication sharedApplication] openURL:url];
版本:
iOS
但显示此确认对话框:
QUESTION
现在,我有了新的要求,无需确认或提示即可拨打电话。那么...... 在NSURL *url = [NSURL URLWithString:@"telnoprompt://637******"];
return [[UIApplication sharedApplication] openURL:url];
省略确认提示时,可以通过某种方式拨打电话吗?
我想要像
这样的东西{{1}}
答案 0 :(得分:1)
NSMutableCharacterSet *characterSet =[NSMutableCharacterSet characterSetWithCharactersInString:@" "];
NSArray *arrayOfComponents = [phone_number componentsSeparatedByCharactersInSet:characterSet];
phone_number = [arrayOfComponents componentsJoinedByString:@""];
NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phone_number];
NSString *escapedUrlString = [phoneURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *phoneURL = [NSURL URLWithString:escapedUrlString];