Tel URI containing * and # is not working on iOS 15 and onwards

229 views Asked by At

Tel URIs containing * and # are not working on iOS 15 and onwards. When I try to execute the following statement

[UIApplication.sharedApplication openURL:[NSURL URLWithString:@"tel://*21*12345#"] options:@{} completionHandler:nil];

It didn't show anything on the device.

NSString *numberToDial = @"*21*12345#";
NSString *encodedNumberToDial = [numberToDial stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", encodedNumberToDial]];

I also try to encode it but it didn't work.

1

There are 1 answers

0
Lou Franco On

According to the docs: https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html

To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone app supports most, but not all, of the special characters in the tel scheme. Specifically, if a URL contains the * or # characters, the Phone app does not attempt to dial the corresponding phone number. If your app receives URL strings from the user or an unknown source, you should also make sure that any special characters that might not be appropriate in a URL are escaped properly. For native apps, use the stringByAddingPercentEscapesUsingEncoding: method of NSString to escape characters, which returns a properly escaped version of your original string.

It appears that this is a limitation of the API and by design because of security.