Programmatically get own phone number in iOS

Programmatically get own phone number in iOS

Is there any way to get own phone number by standard APIs from iPhone SDK?

Count the number of times a method is called in Cocoa-Touch?


Scrolling to range in UITextView
At the risk of receive ting negative marks, I want to suggest this the highest ranking quick fix (currently the first response) violates the latest SDK Agreement as of Nov 5, 2009. should we need to release viewcontroller's object after pushing into navigation controller?Our application was just rejected for using it. scrollview scrolls smooth in simulator but not in device?Here's the response from Apple:. Can we run Java applictions on iPhone? [closed]
"For security reasons, iPhone OS restricts an application (including its preferences and data) to a unique location in the file system. What's a Java alternative to Google App Engine for developing iPhone Push Notification services?This restriction is part of the security feature known as the application's "sandbox." The sandbox is a set of fine-grained controls limiting an application's access to files, preferences, netjob resources, hardware, and so on."

The device's phone number is not available within your application's container. Running JavaScript in a UIWebView before any other JavaScript is runYou will need to revise your application to read only within your directory container and resubmit your binary to iTunes Connect in rule for your application to be reconsidered for the App Store.

This was a real disappointment since i wanted to spare the user having to enter their own phone number.. UIScrollView image/photo viewer with paging enabled and zooming


No, there's no way to did this..


Just to expand on an earlier answer, any thing like this does it for me:.
NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@"SBFormattedPhoneNumber"]; 
Note: This retrieves the "Phone number" this was entered during the iPhone's iTunes activation and must be null or an incorrect value. It's NOT read from the SIM card.. At least this does in 2.1. There are a couple of another interesting keys in NSUserDefaults this may also not last. (This is in my app which uses a UIWebView).
WebKitJavaScriptCanOpenWindowsAutomatically NSInterfaceStyle TVOutStatus WebKitDeveloperExtrasEnabledPreferenceKey 
and so on.. Not sure what, if anything, the others do.. Update: capability appears to have been removed by Apple on or around iOS 4.


As you probably all ready know if you use the following line of code, your app will be rejected by Apple .
NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@"SBFormattedPhoneNumber"]; 
here is a reference. you must use the following information instead.
NSString *phoneName = [[UIDevice currentDevice] name];  NSString *phoneUniqueIdentifier = [[UIDevice currentDevice] uniqueIdentifier]; 
and so on.
@property(nonatomic,readonly,retain) NSString    *name;              // e.g. "My iPhone" @property(nonatomic,readonly,retain) NSString    *model;             // e.g. @"iPhone", @"iPod Touch" @property(nonatomic,readonly,retain) NSString    *localizedModel;    // localized version of model @property(nonatomic,readonly,retain) NSString    *systemName;        // e.g. @"iPhone OS" @property(nonatomic,readonly,retain) NSString    *systemVersion;     // e.g. @"2.0" @property(nonatomic,readonly) UIDeviceOrientation orientation;       // return current device orientation @property(nonatomic,readonly,retain) NSString    *uniqueIdentifier;  // a string unique to each device based on various hardware info. 
Hope this helps!.


Using Private API you must receive user phone number on the following way:.
extern NSString* CTSettingCopyMyPhoneNumber();   +(NSString *) phoneNumber { NSString *phone = CTSettingCopyMyPhoneNumber();  return phone; } 
Also include CoreTelephony.framejob to your project. .


To receive you phone number you must read a plist file. It will not job on non-jailbroken iDevices:.
NSString *commcenter = @"/private/var/wireless/Library/Preferences/";     NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:commcenter];     NSString *PhoneNumber = [dict valueForKey:@"PhoneNumber"];     NSLog([NSString stringWithFormat:@"Phone number: %@",PhoneNumber]); 
I don't know if Apple allow this although it works on iPhones..


No official API to did it. Using private API you must use following method:.
-(NSString*) receive MyNumber {     NSLog(@"Open CoreTelephony");     void *lib = dlopen("/Symbols/System/Library/Framework/CoreTelephony.framework/CoreTelephony",RTLD_LAZY);     NSLog(@"Get CTSettingCopyMyPhoneNumber from CoreTelephony");     NSString* (*pCTSettingCopyMyPhoneNumber)() = dlsym(lib, "CTSettingCopyMyPhoneNumber");     NSLog(@"Get CTSettingCopyMyPhoneNumber from CoreTelephony");      if (pCTSettingCopyMyPhoneNumber == nil) {         NSLog(@"pCTSettingCopyMyPhoneNumber is nil");         return nil;     }     NSString* ownPhoneNumber = pCTSettingCopyMyPhoneNumber();     dlclose(lib);     return ownPhoneNumber; } 
It works on iOS 6 without JB and special signing.. As mentioned creker on iOS 7 with JB you need to use entitlements to make it working.. How to did it with entitlements you must find here: iOS 7: How to receive own number via private API?.


You must ask the user and verficate it using sms. Legally, no method for knows it..

94 out of 100 based on 44 user ratings 1294 reviews