How to get the phone number programmatically

2020-07-27 03:28发布

问题:

Previous answers to the question of how to get the phone number involved using NSUserDefaults and SBFormattedPhoneNumber, but apparently this doesn't work anymore since iOS 4.

So I'm looking for alternative solutions, I've seen mention of using IOKit but can't find any details.

Does anybody know a reliable way to get the phone number (and by reliable I don't mean the hack to try and search the contacts for the owner's contact info).

P.S. I am already aware that the app will be rejected by Apple: but this is not for an App Store app.

回答1:

There is not a way to do this. You can see from these questions:

  • Is it possible to get iphone's phone number programmatically in 2011?
  • Programmatically get own Phone Number in iPhone OS 4.0
  • Programmatically get own phone number in iOS

You can however get a contact's phone number. You can figure out how to do this from here.



标签: ios