3

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?

  • Just a smal comment, according to [RFC3966](http://tools.ietf.org/html/rfc3966) and [RFC2806](http://tools.ietf.org/html/rfc2806) you should not use `tel://` but `tel:`. – rckoenes May 29 '12 at 08:25
  • This isn't an answer, so I'm putting it in the comments. My work-around approach was to copy the phone number (with codes) to the clipboard, and ask the user to paste it into the phone app. This is allowed by iOS, and the only way I could get it to work :( – software evolved May 31 '13 at 17:47

1 Answers1

1

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...)

Alladinian
  • 34,483
  • 6
  • 89
  • 91
  • Tried several approaches: 1. creating a contact record and having the user touch the phone value, 2. Using an embedded webview, 3. Using telprompt URL scheme. Even though several of them required the user to explicitly 'ok' the number being dialed, none of them worked. I eventually just put the string I wanted dialed onto the pasteboard, and put up an alert asking the user to paste it into the phone app. – software evolved Nov 06 '12 at 04:14