问题
How to get cell id using private apis in ios 8.3 as previous core telephony private apis are not working in latest ios sdk 8.3.
回答1:
You can still use this. It's working on iOS 8.3. I don't know how to get signal strength. Apple has changed many things in Core Telephony lately. :(
CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
NSString *carrierNetwork = telephonyInfo.currentRadioAccessTechnology;
NSLog(@"Mobile Network): %@", carrierNetwork);
CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
NSString *mobileCountryCode = [carrier mobileCountryCode];
NSLog(@"Mobile Country Code (MCC): %@", mobileCountryCode);
NSString *mobileNetworkCode = [carrier mobileNetworkCode];
NSLog(@"Mobile Network Code (MNC): %@", mobileNetworkCode);
NSString *carrierName = [carrier carrierName];
NSLog(@"Mobile Network name: %@", carrierName);
NSString *isoCountryCode = [carrier isoCountryCode];
NSLog(@"Mobile Network isoCode: %@", isoCountryCode);
Edit: I found solution how to get signal strength. *! Please note that the solution below makes use of private API and as such will be rejected by Apple when submitted to the App Store.
UIApplication *app = [UIApplication sharedApplication];
NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
NSString *dataNetworkItemView = nil;
for (id subview in subviews) {
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarSignalStrengthItemView") class]]) {
dataNetworkItemView = subview;
break;
}
}
int signalStrength = [[dataNetworkItemView valueForKey:@"signalStrengthRaw"] intValue];
NSLog(@"signal %d", signalStrength);
回答2:
Get CellID, MCC, MNC, LAC, and Network in iOS 5.1
you can visit the above link, and it can get the lac and cell below ios 8.2. if you want to get lac and cell above ios 8.3, you should add the entitlement:
<key>com.apple.CommCenter.fine-grained</key>
<array>
<string>spi</string>
</array>
also, it says your phone need jailbreak.
But really, i can not try on the real phone. if you succeeded , just share, thanks.
来源:https://stackoverflow.com/questions/29795817/get-cellid-mcc-mnc-lac-signal-strength-quality-and-network-in-ios-8-3