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

前端 未结 4 1449
后悔当初
后悔当初 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:02

    I tried iOS 10. But it was not working. But from iOS 12 now its working. do not know how.

    NSString *mobileNocleanedString = @"*454*200#";
    
    NSURL *phoneUrl = [NSURL URLWithString:[NSString  stringWithFormat:@"tel:%@",mobileNocleanedString]];
    
    if ([[UIApplication sharedApplication] canOpenURL:phoneUrl]) {
        [[UIApplication sharedApplication] openURL:phoneUrl];
    }
    
    0 讨论(0)
  • 2020-12-06 15:04

    just replace * by %2a and # by %23

    0 讨论(0)
  • 2020-12-06 15:22

    iOS SDK (Apple URL scheme reference) tells: To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone application supports most, but not all, of the special characters in the tel scheme. Specifically, if a URL contains the * or # characters, the Phone application does not attempt to dial the corresponding phone number.

    So, no luck.

    0 讨论(0)
  • 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()        
    }
    
    0 讨论(0)
提交回复
热议问题