在iOS 8.3中获取CellID,MCC,MNC,LAC,信号强度,质量和网络 [英] Get CellID, MCC, MNC, LAC, Signal strength, quality and Network in iOS 8.3

查看:621
本文介绍了在iOS 8.3中获取CellID,MCC,MNC,LAC,信号强度,质量和网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在ios 8.3中使用私有api获取cell id,因为之前的核心电话私有api在最新的ios sdk 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.

推荐答案

你仍然可以使用它。它适用于iOS 8.3。我不知道如何获得信号强度。 Apple最近在Core Telephony中改变了很多东西。 :(

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

编辑:我找到了解决方案如何获得信号强度。
*!请注意,下面的解决方案使用私有API,因此Apple在提交到App Store时将被拒绝。

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

这篇关于在iOS 8.3中获取CellID,MCC,MNC,LAC,信号强度,质量和网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆