Can I get user's phone number by requesting fo

2019-02-19 21:59发布

问题:

This question already has an answer here:

  • Programmatically get own phone number in iOS 12 answers

I am building an IOS6 app which requires the user's phone number,

Is there a way to ask the user for permission and get the number in programmatic way?

Or he has to manually type it in?

I am using Xcode 4.5 if it matters..

回答1:

You can't get the phone via any easy API within iOS. There might be a way to do it via the technique described in this related question, but this is a few years old and Apple may have closed this hole (which uses an undocumented key). I also wonder if Apple wouldn't allow the app on the App Store for privacy reasons. Probably not.

You'll have to trust the user to type in the correct phone number if you prompt him/her to.