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:
<
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];
}
just replace * by %2a and # by %23
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.
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()
}