xcode 如何检查设备是 LTE、3G、HSPA 还是 Wi-Fi?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12427865/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to check if device is LTE, 3G, HSPA or Wi-Fi?
提问by Devfly
Is it possible to determine which kind of network is on the device when the user is interacting with my app?
当用户与我的应用程序交互时,是否可以确定设备上使用的是哪种网络?
Right now I have the Reachability class and I can differentiate between Wi-Fi and Cellular, but how to check if the Cellular is LTE, 3G, HSPA, EDGE?
现在我有 Reachability 类,我可以区分 Wi-Fi 和 Cellular,但是如何检查 Cellular 是否是 LTE、3G、HSPA、EDGE?
采纳答案by Paul King
As of iOS7, information about the cellular connection is available using CTTelephonyNetworkInfo():
从 iOS7 开始,可以使用 CTTelephonyNetworkInfo() 获得有关蜂窝连接的信息:
let info = CTTelephonyNetworkInfo()
print(“carrierName": " + "\(info.subscriberCellularProvider?.carrierName ?? "Has not been configured for carrier")")
print(“currentRadioAccessTechnology: " + "\(info.currentRadioAccessTechnology ?? "Airplane Mode/No cell connection")")
currentRadioAccessTechnology will show a string that describes the type of connection.
currentRadioAccessTechnology 将显示一个描述连接类型的字符串。
回答by FractalDoctor
There is currently no way to differentiate between different types of cellular network.
目前没有办法区分不同类型的蜂窝网络。
See this questionfor some further information.
有关更多信息,请参阅此问题。