Get CellID, MCC, MNC, LAC, Signal strength, quality and Network in iOS 8.3

帅比萌擦擦* 提交于 2019-11-26 20:33:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!