In IOS,how to remove +-#*() ,which get from address book. for example:
NSString *txt = @"+1(510)1234567"
txt = [NSString stringWithFormat:@"tel://%@", txt];
[[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:txt]];
it's a invalid number to call.
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlToCall]];
is useless for this type number.
could I have some better options except use
[txt stringByReplacingOccurrencesOfString:@"-" withString:@""]
....
I just wanna make a call.
Thanks for your help.
In fact:we can make a call by openURL: the format of call is not "tel://",It is "tel:". So,what I should do is that:
NSString *cleanedString = [[phoneNumber componentsSeparatedByCharactersInSet:
[[NSCharacterSet characterSetWithCharactersInString:@"0123456789-+()"]
invertedSet]] componentsJoinedByString:@""];
NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", cleanedString]];
That's OK.
———————————————————————————————— @"tel://“ isn't the right url to make a call! we must use @"tel:"
if not some number ,as +1 (510) 3436 which
BOOL bCanCall = [[UIApplication sharedApplication]canOpenURL:urlToCall]; will return False. you can't make a call.