Is it possible to detect LTE connection using iOS SDK?

孤人 提交于 2019-12-04 08:54:24

问题


I'm using the reachability API to detect my current connection, but I can only distinguish between WIFI and 3G.

I get the following flags:

LTE: kSCNetworkReachabilityFlagsIsLocalAddress|kSCNetworkReachabilityFlagsIsWWAN|kSCNetworkReachabilityFlagsTransientConnection|kSCNetworkReachabilityFlagsReachable

WIFI: kSCNetworkReachabilityFlagsIsDirect|kSCNetworkReachabilityFlagsReachable

The problem is that LTE returns the same flags as a 3G connection. Is there any way to determine whether the user currently has LTE or 3G?


回答1:


As of iOS 7, you can find this out using the currentRadioAccessTechnology property of CTTelephonyNetworkInfo in the CoreTelephony framework.

#import <CoreTelephony/CTTelephonyNetworkInfo.h>

CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new];

if ([networkInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
    // ...
}



回答2:


I wonder if this hidden Core Telephony API can provide you with enough info for you to determine whether you're attached to an LTE or a slower technology.

CTRegistrationGetCurrentMaxAllowedDataRate();

It might be worth experimenting with.

More about using private APIs here: iPhone mobile number using Core telephony

However, I've read that your app will be rejected by apple if you use private APIs.



来源:https://stackoverflow.com/questions/10159167/is-it-possible-to-detect-lte-connection-using-ios-sdk

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