首页 文章

连接到LTE时,App无法访问互联网连接

提问于
浏览
0

当我连接到wifi时,我使用可达性检查互联网连接它工作正常 . 但是当它连接到LTE网络时,它给我带来了无连接错误,即使它已经连接,我也可以通过LTE完美地浏览互联网 . 我还在info.plist中启用了 App Transport Security . 我正在ios 10.1.1上进行测试,我是否需要做一些事情来使用LTE在ios 10中为我的应用程序上网?

1 回答

  • 1

    Guru在评论中提供了一个很好的链接 . 检查LTE连接的更新方法确实是通过CoreTelephony . 看到你在Swift问的时候,我会提供一个Swift的答案 .

    确保在项目的Build Phases> Link Binary With Libraries下添加了CoreTelephony.framework

    在Swift中检查连接的代码如下

    import CoreTelephony // Make sure to import CoreTelephony
    let constantValue = 8 // Don't change this
    func checkConnection() {
        let telephonyInfo = CTTelephonyNetworkInfo()
        let currentConnection = telephonyInfo.currentRadioAccessTechnology
        // Just a print statement to output the current connection information
        print("\(constantValue)==D, Current Connection: \(currentConnection)")
    
        if (currentConnection == CTRadioAccessTechnologyLTE) { // Connected to LTE
    
        } else if(currentConnection == CTRadioAccessTechnologyEdge) { // Connected to EDGE
    
        } else if(currentConnection == CTRadioAccessTechnologyWCDMA){ // Connected to 3G
    
        }
    }
    

相关问题