我想从ios本机应用程序中呼叫电话号码
代码如下:
NSString *allString = [NSString stringWithFormat:@"tel:%@",phoneNum];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:allString]]在IOS10.2中,一些人可以直接自动调用,但另一些人会得到一个确认对话框。
那么,我应该怎么做才能让所有的iphones都能直接自动通话呢?
发布于 2016-12-28 17:04:36
在视图控制器中使用
func doPhoneCall(_ number: String?) {
if var number = number {
number = number.replacingOccurrences(of: " ", with: "")
if let phoneCallURL = URL(string:"tel://\(number)") {
openURL(phoneCallURL)
}
}
}
func openURL(_ url: URL) {
let application = UIApplication.shared
if (application.canOpenURL(url)) {
application.openURL(url);
}
}https://stackoverflow.com/questions/41358339
复制相似问题