简体   繁体   中英

How to dial a phone number with “##”?

I want to dial a phone number like "##8004664411" in IPhone.

If I dial the number "8004664411",it works.But if the number contains the symbol"##",it doesn't work.

Here is the code that I am using which is not working:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://##8004664411"]];

Is the escape character wrong?

I am afraid that you simply cannot dial a number containing * or # characters. It seems that Apple doesn't allow them in a dial string for security reasons. Below is the relevant part of the documentation.

From Apple's documentation :

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. If your application 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 applications, use the stringByAddingPercentEscapesUsingEncoding: method of NSString to escape characters, which returns a properly escaped version of your original string.

Note: The stringByAddingPercentEscapesUsingEncoding: part does not apply to * and # (I've tried it yes...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM