Get CellID, MCC, MNC, LAC, Signal strength, qualit

2019-01-23 00:00发布

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.

2条回答
我命由我不由天
2楼-- · 2019-01-23 00:20

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.

查看更多
干净又极端
3楼-- · 2019-01-23 00:31

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);
查看更多
登录 后发表回答