Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...