1

As far as my understanding, there is no public API available in iPhone SDK to find the users mobile number.

Can we find the mobile number of iPhone user using the Core telephony framework added in 4.0 SDK?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Anil Sivadas
  • 1,658
  • 3
  • 16
  • 26

3 Answers3

7

Yes, you can, but it's tricky. It involves using iOS private API, which will determine Apple to reject your app in case you want to post it on the App Store.

Here's what I did:

  1. download and install the class-dump utility: http://www.codethecode.com/projects/class-dump/
  2. in the command line go to this folder: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/CoreTelephony.framework and perform the following command:

    class-dump CoreTelephony > CoreTelephony.h

    This will create a header file in the current directory. Move this file in the desired directory.

  3. in your Xcode project, import the CoreTelephony.framework (Xcode 4: click on the project target -> Build Phases tab -> Link Binary With Libraries -> + -> select the CoreTelephony.framework in the iOS list -> click Add)
  4. import the CoreTelephony.h file using the same method as above Xcode 4: click on the project target -> Build Phases tab -> Link Binary With Libraries -> + -> Add Other -> select your file in the Finder)
  5. at the end of the CoreTelephony.h file, add the following:

    extern NSString *CTSettingCopyMyPhoneNumber();
    
  6. import the CoreTelephony.h in your code and call the above function.
  7. when building the project, you may find that there are compilation errors in the CoreTelephony.h - usually an interface declaration that needs to be moved before another interface declaration or protocol sequences written incorrectly
  8. in case you have linking errors, use the following linking flags in the build settings of your project target:

    -force_flat_namespace 
    -undefined suppress 
    

    (Xcode 4: click on the project target -> Build Settings tab -> Linking -> double-click on the values section of the Other Linker Flags property -> + -> add flags above -> Done

  9. by now you should be able to get that phone number :)
  • Since I can't add more than 2 links in a post, due to my current status, please see this post for more useful links: [http://www.hackint0sh.org/f9/57803.htm#post936233] – Cristina Botez Feb 08 '12 at 10:50
  • 1
    just for the record, you don't need to include the CoreTelephony.h file to the project, just add extern declaration. – mja May 23 '12 at 14:37
  • This works brilliantly. Simply add extern NSString *CTSettingCopyMyPhoneNumber(); to your class and call it. Oh, and don't submit to the store with that call, obviously. – Andrew Zimmer May 17 '13 at 21:15
3

No, the CoreTelephony framework provides some basic information about the carrier and limited info about calls, not much else.

The limited information includes things like the amount of current active calls, the call ID (not a mobile number, just a unique ID that the OS uses to track the particular call) and the state of a call, like whether the call is on hold or not.

The main feature in CallTelephony is an API to check whether or not a carrier allows VoIP over 3G.

Jasarien
  • 58,279
  • 31
  • 157
  • 188
  • is the call id goves by iphone os is same for same user or it chooses id randomly? – Pankaj Kainthla Sep 21 '10 at 05:11
  • 2
    As far as I know, there's no correlation between user and ID. The ID simply identifies one call amongst many. If the same person calls again, I'm pretty sure they'll get a new ID. The ID is unique to the call, not to the user/person. – Jasarien Sep 21 '10 at 08:58
0

if u want to get cell phone number from call log then see this link it may be helpful. But i am not sure that after using this apple will aprove ur app. call details

ios
  • 552
  • 5
  • 22