how to retrieve the user phone number programmatically?

NSString *phoneNumber = [[NSUserDefaults standardUserDefaults] objectForKey:@”SBFormattedPhoneNumber”];

NSLog(@”Your phone number is %@”, phoneNumber);

Check these two links:
        http://www.alexcurylo.com/blog/2008/11/15/snippet-phone-number/
        http://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-iphone-os

Blogged with the Flock Browser
Advertisements

5 Responses to “how to retrieve the user phone number programmatically?”

  1. Peter Says:

    This does not work in my app, the SBFormattedPhoneNumber key is not present in the standardUserDefaults dictionary. I only see following keys:
    TVOutStatus,
    AppleICUForce24HourTime,
    NSInterfaceStyle,
    AppleLocale,
    AppleKeyboards,
    NSLanguages,
    AppleKeyboardsExpanded,
    AppleLanguages

  2. babyfish0226 Says:

    Not work in 2.2.1.

  3. Dan Says:

    This only works on a real iPhone device, not in the simulator. You can code your app to handle the missing value and return a dummy value for debugging and testing. I’ve verified this in all released versions of the iPhone OS.

  4. Benoit Says:

    Well I does not seem to work on OS 3.0. I tested it on my device. Has anyone managed to get this on 3.0?

  5. Michael Says:

    This number is only there on a large percentage of iPhones, for others it is not there.

    It is set in the settings.app for those of you who don’t have it set on your particular device and you want it to be.

    You may face rejection from apple if they catch you doing this.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: