I'm using the address book of the iPhone to call numbers using telprompt:. A number with spa开发者_C百科ces 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?
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]]];
See section 3, "URI Syntax", of RFC 3966: The tel
URI for Telephone Numbers.
精彩评论