需要在iOS中实现打电话功能。
参考:
ios – Make a phone call programmatically – Stack Overflow
telprompt://
不是官网指定的-》以后可能没用
最好加上:canOpenURL
objective c – How to call a phone number from ios app? – Stack Overflow
Apple URL Scheme Reference - Phone Links
jatraiz/RZTelpromptExample: RZTelpromptExample
【总结】
后来的后来,整理出对应函数了:
<code> /*************************************************************************** * Phone functions ***************************************************************************/ func doPhoneCall(_ curPhone:String) -> Bool { var callOk = false if curPhone.notEmpty { let phoneTelStr = "tel://" + curPhone gLog.verbose("phoneTelStr=\(phoneTelStr)") //phoneTelStr=tel://13800001111 if let phoneTelNsurl = URL(string: phoneTelStr) { gLog.verbose("phoneTelNsurl=\(phoneTelNsurl)") //phoneTelNsurl=tel://13800001111 let application:UIApplication = UIApplication.shared if application.canOpenURL(phoneTelNsurl) { callOk = true UIApplication.shared.openURL(phoneTelNsurl) } else { //Note: //in iOS Simulator will fail: //canOpenURL: failed for URL: "tel://13800001111" - error: "This app is not allowed to query for scheme tel" print("application can not open: \(phoneTelNsurl)") } } } else { print("can not call for empty phone") } return callOk } </code>
详见:
https://github.com/crifan/crifanLib/blob/master/swift/CrifanLib/CrifanLib.swift
转载请注明:在路上 » 【已解决】iOS的swift中实现打电话