Call to a number, which contain #. (IPhone SDK)

前端 未结 4 1455
后悔当初
后悔当初 2020-12-06 14:25

I need to make call to a number, that start with #. For example phone number in Russia looks like +79123817711 and I need to call #79123817711. I\'m trying this:

<         


        
4条回答
  •  死守一世寂寞
    2020-12-06 15:25

    I have achieved this by encoding the ussd and pass it in the url and it works just fine

    Here is an example:

    extension String {
          /// Calling ussd number
          func callUSSD() {
              guard let urlString = self.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) else { return }
              guard let url = URL(string: "tel://\(urlString)") else { return }
             UIApplication.shared.open(url, options: [:])
        }
    }
    

    Usage:

    @IBAction func callTapped(_ sender: UIButton) {
        "*1124#".callUSSD()        
    }
    

提交回复
热议问题