快速从手机对话框回到应用程序

时间:2019-01-07 10:03:18

标签: swift core-telephony

打完电话后是否可以返回我的应用程序?使用此代码进行通话

this还是真实的吗?

func callNumber(phoneNumber:String) {

        completeStringToSend.append("calling to: \(phoneNumber) \n")
        /*
         dialog box for user when sending a call cannot be avoided.
         https://developer.apple.com/library/archive/releasenotes/General/RN-iOSSDK-10.3/
         https://support.apple.com/en-gb/HT207617
         */

        if let phoneCallURL = URL(string: "telprompt://\(phoneNumber)") {

            let application:UIApplication = UIApplication.shared
            if (application.canOpenURL(phoneCallURL)) {
                if #available(iOS 10.0, *) {
                    application.open(phoneCallURL, options: [:], completionHandler: nil)
                } else {
                    // Fallback on earlier versions
                    UIApplication.shared.openURL(phoneCallURL as URL)
                }
            }
        }
    }

0 个答案:

没有答案