Im on a application that receive data from server, the problem was when user connect cellular data
to (not 3G
or WIFI
), it tak e ages to receive data.
I had implemented this code to Answer but im not sure if it's effective or not, sometimes it's giving me an Accura Te type, and sometimes it don ' t.
Here is my code:
-(void) Newtworktype {Nsarray *subviews = [[[UIApplication Sharedapplication] valueforkey:@ "StatusBar"] valueforkey:@ "Foregroundview"]subviews]; NSNumber *datanetworkitemview = nil;for (id subview in subviews) {if ([Subview iskindofclass:[nsclassfromstring (@ "UISta Tusbardatanetworkitemview ") class]) {Datanetworkitemview = Subview; Break }}switch ([[Datanetworkitemview valueforkey:@ "Datanetworktype"]integervalue]) {case 0:nslog (@ "No WiFi or Cellu Lar "); Break Case 1:nslog (@ "2G"); Break Case 2:nslog (@ "3G"); Break Case 3:nslog (@ "4G"); Break Case 4:nslog (@ "LTE"); Break Case 5:nslog (@ "Wifi"); Break Default:break;}}
Make sure, the is isn't Status bar
hidden in your application. If it's not visible it'll always return No wifi or cellular
because your C Ode reads the text in the Status bar
thats all.
The best-of-the-solve your problem, just make the not hidden then the Status bar
application would get the text about th E Network type.
Determine the network type
GPRS 2G (2.5) General Packet Radia Service 114kbps
EDGE 2G (2.75G) Enhanced Data rate for GSM Evolution 384kbps
The UMTS 3G WCDMA 3G Universal Mobile telecommunication System complete 3G Mobile communication technology standard
CDMA 2G Telecom Code Division multiple Access Code Division multiple address
Evdo_0 3G (EVDO full CDMA2000 1xev-do) evolution-data only (Data Optimized) 153.6kps-2.4mbps belongs to 3G
Evdo_a 3G 1.8mbps-3.1mbps 3G Transition, 3.5G
1xRTT 2G CDMA2000 1xRTT (RTT-radio transmission technology) 144kbps 2G Transition,
HSDPA 3.5G High-speed downlink packet access 3.5G WCDMA downlink Packet Access 14.4mbps
HSUPA 3.5G Fast Uplink Packet access high-speed uplink packet access 1.4-5.8 Mbps
HSPA 3G (min hsdpa,hsupa) high speed Packet Access
IDEN 2G Integrated Dispatch Enhanced Networks Integrated Digital-enhanced network (2G, from Wikipedia)
Evdo_b 3G ev-do rev.b 14.7Mbps downlink 3.5G
LTE 4G Long term Evolution fdd-lte and Tdd-lte, 3G transition, upgraded LTE advanced is 4G
EHRPD 3G CDMA2000 to LTE 4G Intermediate product evolved high rate Packet Data HRPD Upgrade
HSPAP 3G HSPAP faster than HSDPA
From IOS 7 on your can use:
CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];NSLog(@"Current Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);[NSNotificationCenter.defaultCenter addObserverForName:CTRadioAccessTechnologyDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { NSLog(@"New Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);}];
I have also found this to detect a slow or fast connection:
-(BOOL) Isfast: (nsstring*) Radioaccesstechnology {if ([radioaccesstechnology isequaltostring: Ctradioaccesstechnologygprs]) {return NO; } else if ([radioaccesstechnology Isequaltostring:ctradioaccesstechnologyedge]) {return NO; } else if ([radioaccesstechnology ISEQUALTOSTRING:CTRADIOACCESSTECHNOLOGYWCDMA]) {return YES; } else if ([radioaccesstechnology ISEQUALTOSTRING:CTRADIOACCESSTECHNOLOGYHSDPA]) {return YES; } else if ([radioaccesstechnology Isequaltostring:ctradioaccesstechnologyhsupa]) {return YES; } else if ([radioaccesstechnology isequaltostring:ctradioaccesstechnologycdma1x]) {return YES; } else if ([radioaccesstechnology isequaltostring:ctradioaccesstechnologycdmaevdorev0]) {return YES; } else if ([radioaccesstechnology Isequaltostring:ctradioaccesstechnologycdmaevdoreva]) {return YES; } else if ([radioaccesstechnology Isequaltostring:ctradioaccesstechnologycdmaevdorevb]) {return YES; } else if ([radioaccesstechnology ISEQUALTOSTRING:CTRADIOACCESSTECHNOLOGYEHRPD]) {return YES; } else if ([radioaccesstechnology Isequaltostring:ctradioaccesstechnologylte]) {return YES; } return YES;