I'm using the address book of the iPhone to call numbers using telprompt:. A number with spaces and dashes doesn't work, while one with plus and numbers only does work. The iphone itself doesn't allow typing them, but synchronising with the mac gets me lots of (invalid?) phone numbers. Which characters are allowed, and why?
Asked
Active
Viewed 1,226 times
2 Answers
3
Try using this code, it leaves only numbers in the phone number string:
NSString* phone = @"477 (38) 232-35-47";
//@"477 (38) 232-35-47"
phone = [[phone componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""];
//@"477382323547"
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@", phone]]];

Alexey Golikov
- 652
- 8
- 19
1
See section 3, "URI Syntax", of RFC 3966: The tel
URI for Telephone Numbers.

Community
- 1
- 1

Jeremy W. Sherman
- 35,901
- 5
- 77
- 111
-
1so spaces are not allowed, but dashes are. – Stephan Eggermont May 31 '11 at 08:46