Getting the local iPhone number through SDK

前端 未结 4 1139
没有蜡笔的小新
没有蜡笔的小新 2020-12-10 00:31

I am looking for a SDK API to retrieve the device\'s local phone number
from the SIM card. Is there a way to do it?

相关标签:
4条回答
  • 2020-12-10 00:43

    This method refers to the number stored in iTunes at time of activation... so, don't use it. From 4.x you can take advantage from CoreTelephony framework to get many information about the network, but still no number...

    0 讨论(0)
  • 2020-12-10 00:44

    Take a look at this blog post here.

    NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@”SBFormattedPhoneNumber”]; NSLog(@”Phone Number: %@”, num);
    

    Adrian

    0 讨论(0)
  • 2020-12-10 00:53
    CFShow([[NSUserDefaults standardUserDefaults] objectForKey:@"SBFormattedPhoneNumber"]); 
    
    NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Preferences/.GlobalPreferences.plist"];  
    NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];  
    CFShow(dict); 
    
    0 讨论(0)
  • 2020-12-10 00:57

    There's no reliable way. You'll find code online that tells you to look up SBFormattedPhoneNumber, and sometimes that works, but not consistently. Mostly it's people who brought their phone number over from another cell carrier. In those cases, you get a phone number, but not one for the current phone, and not one that's guaranteed to be valid for anything at all (it may not even be unique).

    I have no basis for saying whether this is a few people or a lot, but it's an undocumented key that's inherently unreliable.

    0 讨论(0)
提交回复
热议问题