ios - iOS如何在同时开启wifi的情况下检测蜂窝数据

标签 ios

我想使用蜂窝数据连接网络优先级。

那么当wifi打开时,有没有一种方法可以检测蜂窝数据的状态?

最佳答案

您应该能够通过Core Telephony框架获取蜂窝数据状态。 CTTelephony​Network​Info 类具有current​Radio​Access​Technology属性,该属性会告诉您当前注册的蜂窝网络类型,例如CTRadioAccessTechnologyLTE。您可以在Core TelephonyConstants Overview中找到所有可能的值。

let info = CTTelephonyNetworkInfo()
if info.currentRadioAccessTechnology != nil {
    print("Cellular Data available")
}

关于ios - iOS如何在同时开启wifi的情况下检测蜂窝数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43017571/

相关文章:

ios - Flutter iOS 14.0 构建错误 : Failed to register observatory port with mDNS

ios - 滚动出界时 WKWebView 会发生什么

ios - 从一组按钮中标记以使用标记参数打开新 View

ios - 旋转 iOS 的 UIImageView 问题

ios - AVAssetExportSession exportAsynchronouslyWithCompletionHandler : method Not Called

ios - UITableView 与 UITextView 对齐

ios - 位置管理器 :didFailWithError: not called if user Location Services are off

ios - 核心数据和持有 NSManagerObject

ios - 按标签查找对象

iphone - iOS - CFSocket 没有得到回调