App can't access internet connection when connected to LTE

506 views Asked by At

I use reachability to check internet connection when I connect to wifi it works fine. But when its connected to LTE network it gives me No Connection error, even though it is connected, I can browse the internet perfectly with LTE. I have also enabled App Transport Security in info.plist. I'm testing it on ios 10.1.1, do I have to do something to get internet access for my app in ios 10 using LTE?

1

There are 1 answers

0
Justin Lennox On

Guru provided an excellent link in his comment. An updated way to check an LTE connection is indeed through CoreTelephony. Seeing as you asked in Swift though, I'll provide a Swift answer.

Make sure you have CoreTelephony.framework added under your project's Build Phases > Link Binary With Libraries

The code to check the connection in Swift would be as follows

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

    }
}