ios 如何获取 iPhone 设备的电话号码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6041605/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get the phone number of my iPhone device?
提问by user758741
Possible Duplicate:
Programmatically get own phone number in iPhone OS
I am new in iPhone technology. I am currently building a dialler application in which requires the phone number of my iPhone form my SIM card.
我是 iPhone 技术的新手。我目前正在构建一个拨号应用程序,其中需要从我的 SIM 卡中获取我 iPhone 的电话号码。
How can I get the phone number of my iPhone device?
如何获取 iPhone 设备的电话号码?
回答by Claus Broch
The phone number is not accessable from any Apple public API which means you can't get it.
电话号码无法从任何 Apple 公共 API 访问,这意味着您无法获得它。
If you are implementing a dialer application I can't see what you would nee the own phone number for. It's not like you are going to call yourself?
如果您正在实施拨号器应用程序,我看不出您需要自己的电话号码来做什么。不是说要给自己打电话吗?
回答by rckoenes
You can get the users phone number from the NSUserDefault:
您可以从 NSUserDefault 获取用户电话号码:
[[NSUserDefaults standardUserDefaults] objectForKey:@"SBFormattedPhoneNumber"]
But this will only work if the user has entered his phone number. There is no way in the official SDK to read anything from the SIM card.
但这只有在用户输入了他的电话号码时才有效。官方 SDK 无法从 SIM 卡中读取任何内容。