我找到了一种让用户通过我的应用程序拨打电话的方法。但是,我希望用户能够选择从中拨打电话的应用程序(电话、Viber、Skype),类似于社交共享功能,但用于电话。
我现在用这个直接拨号:
public static func callNumber(phoneNumber: String) {
let cleanPhoneNumber = phoneNumber.trimmingCharacters(in: CharacterSet(charactersIn: "01234567890").inverted)
if let phoneCallURL = URL(string: "tel://\(cleanPhoneNumber)") {
if UIDevice.current.model.range(of: "iPad") != nil {
print("Your device doesn't support this feature.")
} else {
let application: UIApplication = UIApplication.shared
if (application.canOpenURL(phoneCallURL)) {
let mobileNetworkCode = CTTelephonyNetworkInfo().subscriberCellularProvider?.mobileNetworkCode
if( mobileNetworkCode == nil) {
print(" No sim present Or No cellular coverage or phone is on airplane mode.")
}
else {
application.openURL(phoneCallURL);
}
}
}
}
}
有没有办法让它像社交分享一样快速工作。谢谢您的帮助。