1

I have the following code:

phoneNumber = (NSString*)CFBridgingRelease(ABMultiValueCopyValueAtIndex(phones, i));
NSString *phoneNumberURLString = [[NSString alloc] initWithFormat:@"tel://%@", phoneNumber];
            NSURL *phoneURL = [[NSURL alloc] initWithString:phoneNumberURLString];
            [[UIApplication sharedApplication] openURL:phoneURL];

However, the issue with this is that, sometimes a certain phone number doesn't get called: for example if phoneNumber is (520) 123-1232, then this doesn't call the phone. Any idea on how to standarize the phone number format such that this method works for all cases?

debracey
  • 6,517
  • 1
  • 30
  • 56
aherlambang
  • 14,290
  • 50
  • 150
  • 253
  • is it only that number you specified? which numbers don't get called? – Jeeter Dec 31 '12 at 01:26
  • Are your running in the simulator or on a device...look at: http://stackoverflow.com/questions/3282778/make-a-call-from-my-iphone-application?rq=1 – Groot Dec 31 '12 at 01:27
  • It's not just that number I specified.. essentially all numbers that is the following +15208238172 worked.. however if it's something like (520) 082 8172 then it didn't work – aherlambang Dec 31 '12 at 01:29

1 Answers1

0

It is the spaces in the number. A space is not a valid URL character. It must be encoded propery as %20.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • I don't have the docs handy. Look in the NString docs for method with a name like `stringByAddingPercentEscapes`. – rmaddy Dec 31 '12 at 01:32