如何在 ios 8.3 中使用私有(private) api 获取小区 ID,因为以前的核心电话私有(private) api 在最新的 ios sdk 8.3 中不起作用。
最佳答案
您仍然可以使用它。它适用于 iOS 8.3。我不知道如何获得信号强度。 Apple 最近对 Core Telephony 进行了很多更改。 :(
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);
编辑:我找到了如何获取信号强度的解决方案。 *!请注意,以下解决方案使用私有(private) API,因此在提交到 App Store 时会被 Apple 拒绝。
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);
关于ios - 在 iOS 8.3 中获取 CellID、MCC、MNC、LAC、信号强度、质量和网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29795817/