iOS 之拨打电话的方法


- (IBAction)didClickCall:(id)sender {
    // 可能审核被拒
    //NSString *phoneNumber = [NSString stringWithFormat:@"telprompt://%@", @"4006666536"];
    
    // 直接拨打电话,不弹出提示框
    NSString *phoneNumber = [NSString stringWithFormat:@"tel:%@", @"4006666536"];
    //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];

    //
    UIWebView *callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:phoneNumber]]];
    [self.view addSubview:callWebview];
}


    @objc func didClickCall() {
        let courierPhone = "4006666536"
        
        // 可能审核被拒
        //let phoneNumber = "telprompt://\(courierPhone)"
        
        // 直接拨打电话,不弹出提示框
        let phoneNumber = "tel:\(courierPhone)"
        //UIApplication.shared.openURL(URL(string: phoneNumber)!)
        
        //
        let callWebview = UIWebView()
        callWebview.loadRequest(URLRequest(url: URL(string: phoneNumber)!))
        addSubview(callWebview)
    }


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。