views:

1506

answers:

4

I am looking for a SDK API to retrieve the device's local phone number
from the SIM card. Is there a way to do it? Thanks. Mike

+1  A: 

A search through Google revealed this:

http://arstechnica.com/apple/news/2009/01/iphone-dev-user-phone-numbers.ars

Jonas
A: 

There's no reliable way. You'll find code online that tells you to look up SBFormattedPhoneNumber, and sometimes that works, but not consistently. Mostly it's people who brought their phone number over from another cell carrier. In those cases, you get a phone number, but not one for the current phone, and not one that's guaranteed to be valid for anything at all (it may not even be unique).

I have no basis for saying whether this is a few people or a lot, but it's an undocumented key that's inherently unreliable.

Tom Harrington
A: 

http://blog.timeister.com/2009/06/25/objective-c-get-iphone-number/

code:

NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@”SBFormattedPhoneNumber”]; NSLog(@”Phone Number: %@”, num);

Adrian

A: 

This method refers to the number stored in iTunes at time of activation... so, don't use it. From 4.x you can take advantage from CoreTelephony framework to get many information about the network, but still no number...

Fabio Ricci