Call the number that contains #. (IPhone SDK)

I need to call a number starting with C #. For example, a phone number in Russia looks like +79123817711, and I need to call # 79123817711. I try this:

NSURL *url = [NSURL URLWithString:@"tel://#79123817711"];
[[UIApplication sharedLibrary] openURL:url];

But he replaced # with% 23 and, of course, did not make the call.

Is there any way to make such calls.

I know this is not a call, this is a USSD request. But the function of this ussd looks like a call.

+4
source share
4 answers

iOS SDK ( URL- Apple) : , "" , , . , URL- * #, "" .

, .

+6

* % 2a # % 23

0

iOS 10. . iOS 12 . .

NSString *mobileNocleanedString = @"*454*200#";

NSURL *phoneUrl = [NSURL URLWithString:[NSString  stringWithFormat:@"tel:%@",mobileNocleanedString]];

if ([[UIApplication sharedApplication] canOpenURL:phoneUrl]) {
    [[UIApplication sharedApplication] openURL:phoneUrl];
}
0
source

I achieved this by encoding ussd and passing it to 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: [:])
    }
}

Using:

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

Source: https://habr.com/ru/post/1761264/


All Articles