Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine the iOS connection type (Edge, 3G, 4G, Wifi)? [duplicate]

Tags:

How is it possible to determine the iOS connection type?

I want to know if there is Edge, 3G, 4G oder Wifi available at this moment on my device.

This information I need to load different data with a different size.

So, I don't want to load an image of 4 MB with a connection type "Edge".

like image 461
Karl Avatar asked Dec 09 '14 13:12

Karl


People also ask

How do I change my iPhone from 4G to E?

On your iPhone, go to Settings > Cellular > Cellular Data Options and tap Enable LTE or Settings > Mobile Data and tap Enable LTE.

How does Nwpathmonitor check Internet connection?

You can use the function usesInterfaceType(_:) to check which interface type this network path uses. This is the most effective way to figure out if your app is connected over WiFi, cellular or ethernet. print(“It's WiFi!”)

Where is network settings on iPhone?

Go to Settings > Cellular, then turn Cellular Data on or off for any app (such as Maps) or service (such as Wi-Fi Assist) that can use cellular data. If a setting is off, iPhone uses only Wi-Fi for that service.


1 Answers

For swift we can use following function:

func getNetworkType()->String {     do{         let reachability:Reachability = try Reachability.reachabilityForInternetConnection()         do{             try reachability.startNotifier()             let status = reachability.currentReachabilityStatus             if(status == .NotReachable){                 return ""             }else if (status == .ReachableViaWiFi){                 return "Wifi"             }else if (status == .ReachableViaWWAN){                 let networkInfo = CTTelephonyNetworkInfo()                 let carrierType = networkInfo.currentRadioAccessTechnology                 switch carrierType{                 case CTRadioAccessTechnologyGPRS?,CTRadioAccessTechnologyEdge?,CTRadioAccessTechnologyCDMA1x?: return "2G"                 case CTRadioAccessTechnologyWCDMA?,CTRadioAccessTechnologyHSDPA?,CTRadioAccessTechnologyHSUPA?,CTRadioAccessTechnologyCDMAEVDORev0?,CTRadioAccessTechnologyCDMAEVDORevA?,CTRadioAccessTechnologyCDMAEVDORevB?,CTRadioAccessTechnologyeHRPD?: return "3G"                 case CTRadioAccessTechnologyLTE?: return "4G"                 default: return ""                 }               }else{                 return ""             }         }catch{             return ""         }      }catch{         return ""     }   } 
like image 149
Sachin Agarwal Avatar answered Sep 25 '22 15:09

Sachin Agarwal