iOS 喚起撥打電話,打電話功能


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
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM