使用特殊字符的swift 3电话#

时间:2017-06-12 18:20:57

标签: ios swift3 phone-call

我在电话中使用#时遇到问题,在显示(tel://*155*222222*123%23)的控制台中,我认为问题是使用#。我查了一下,有些人说不允许在电话中使用特殊字符。

var code = String()
var ID = String()
var Card = String()
@IBAction func ChargePhone(_ sender: Any) {
    ID = "123"
    ID = ID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
    Card = "222222"
    code = "*155*"


        var RESULT = "\(code)\(Card)*\(ID)#"

        RESULT = RESULT.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!
        if let url = URL(string: "tel://\(RESULT)"), UIApplication.shared.canOpenURL(url) {
            if #available(iOS 10, *) {
                UIApplication.shared.open(url)
            } else {
                UIApplication.shared.openURL(url)
            }
 }

1 个答案:

答案 0 :(得分:1)

手机应用程序不允许iOS上的电话号码重定向上的特殊字符。

参考: https://developer.apple.com/library/content/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html