4

如何在 ios 8.3 中使用私有 api 获取单元 id,因为以前的核心电话私有 api 在最新的 ios sdk 8.3 中不起作用。

4

2 回答 2

5

你仍然可以使用这个。它适用于 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);

编辑:我找到了如何获得信号强度的解决方案。*!请注意,以下解决方案使用私有 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);
于 2015-04-23T10:14:38.057 回答
0

在 iOS 5.1 中获取 CellID、MCC、MNC、LAC 和网络

你可以访问上面的链接,它可以得到ios 8.2以下的lac和cell。如果你想在 ios 8.3 以上获得 lac 和 cell,你应该添加权利:

<key>com.apple.CommCenter.fine-grained</key>
<array>
    <string>spi</string>
</array>

另外,它说你的手机需要越狱。

但实际上,我无法在真机上试用。如果你成功了,请分享,谢谢。

于 2015-10-19T13:38:22.583 回答