简体   繁体   English

如何在 Swift 中拨打电话号码后拨打分机号

[英]How to call an extension after dialing a phone number in Swift

How would I call an extension after dialing a phone number?拨打电话号码后如何拨打分机号?

This is how I make the call but I'm not really sure where to go from here.这就是我拨打电话的方式,但我不确定从哪里开始。

@IBAction func phoneLaunch(sender: AnyObject) {
    callNumber("\(newArray[3])")
}

I don't know how to keep dialing numbers correctly after a phone number is called.我不知道如何在拨打电话号码后保持正确拨号。

This is how I solved the issue, you just have to insert a comma in between the phone number and the extension.我就是这样解决这个问题的,你只需要在电话号码和分机号之间插入一个逗号。

@IBAction func phoneLaunch(sender: AnyObject) {
    callNumber("phoneNumber", extensionNum: "extensionNumber")
}

private func callNumber(phoneNumber:String, extensionNum:String) {
    if let phoneCallURL:NSURL = NSURL(string: "tel://\(phoneNumber),\(extensionNum)") {
        let application:UIApplication = UIApplication.sharedApplication()
        if (application.canOpenURL(phoneCallURL)) {
            application.openURL(phoneCallURL);
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM