1、UIWebView喚起
- 效果:
- 打電話前會有提示,打完電話后會回到原來的程序。系統版本13.4.1,喚起提示框,速度較慢。使用UIWebView喚起,不確定具體應用場景。
NSString *phoneNumber = @"10086";
NSMutableString *str = [[NSMutableString alloc] initWithFormat:@"tel:%@", phoneNumber];
UIWebView *callWebview = [[UIWebView alloc] init];
[callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
[self.view addSubview:callWebview];
2、UIApplication喚起
- 效果:
- 打電話前會有提示,打完電話后會回到原來的程序。系統版本13.4.1,喚起提示框,速度正常。
NSString *phoneNumber = @"10086";
NSMutableString *str = [[NSMutableString alloc] initWithFormat:@"tel:%@", phoneNumber];
UIApplication *application = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:str];
if (@available(iOS 10.0, *)) {
[application openURL:URL options:@{} completionHandler:^(BOOL success) {
// OpenSuccess=選擇 呼叫 為 1 選擇 取消 為0
NSLog(@"OpenSuccess=%d",success);
}];
}
else {
// Fallback on earlier versions
}