问题
Is it possible to get information about the Carrier currently in use? CoreTelefony gives back information about the SIM carrier.
I haven't found any article on internet talking about this topic. Since the SIM can be the same also when the user moves in other countries, I would like to check the current network information the phone is using.
Any chance to achieve this result?
I'm interested in both iOS and Android code.
回答1:
I ran into this problem a while back, and I managed to find a way that works for my purposes. It's not pretty and not future proof, it is also not documented. But I do currently have an app in the AppStore that uses this.
Oh, and it's only tested on iOS 7.0 - 8.2!
So yeah, for iOS I know it's possible to find the MMC and MNC, and that way you find the country and provider:
// This is the location of the operator symlink
static NSString * operatorPListSymLinkPath = @"/var/mobile/Library/Preferences/com.apple.operator.plist";
// Here we get the path where the symlink points to
NSFileManager * fileManager = [NSFileManager defaultManager]
NSError * error;
NSString * operatorPListPath = [fileManager destinationOfSymbolicLinkAtPath:operatorPListSymLinkPath error:&error];
The operator path contains a few numbers, of which the first 3 are the MCC (Mobile Country Code) of the provider and the few after that is the MNC (Mobile Network Code)
I just wanted to find the country (MCC), so I used this:
operatorPListPath = [operatorPListPath stringByTrimmingCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"1234567890"] invertedSet]];
NSString * countryMCC = [operatorPListPath substringToIndex:3];
All you need is a MCC > Country dictionary and a MNC > Network dictionary to check what those codes stand for
Can't help you out with Android though.. :)
来源:https://stackoverflow.com/questions/28396220/find-carrier-info-in-use-not-the-sim-one