iOS 之拨打电话的方法

2019-02-19  本文已影响0人  willokyes

- (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)
    }


上一篇下一篇

猜你喜欢

热点阅读