How to get Apps Using WLAN & Cellular Setting
setting status in the picture below ?
How can I check that status(None, WLAN, WLAN&Cellular) for my App, so that I can show an alert to remind user of open this switch ~
Asked
Active
Viewed 2,097 times
4

Shawn Wang
- 2,314
- 1
- 16
- 19
-
1You mean the setting for your app, not for all apps, correct? – Pekka Oct 05 '16 at 16:15
-
Yep ,I want to guide user to open this switch. Sometimes the wifi is connected, but this switch for my app is closed ,but users don't know this ,they may blame me cause they think something wrong with my app or server :( – Shawn Wang Oct 06 '16 at 03:48
-
There may be no way to do this - you may have to explain to the user what they need to do. – Pekka Oct 06 '16 at 07:38
1 Answers
2
When Reachability is NotReachable
, there are 2 situation ,
- The wifi is not connected
- The
Apps Using WLAN & Cellular Setting
is off
If we can get the SSID of current wifi, we can judge that the wifi is connected and the network switch is off ~
#import <SystemConfiguration/CaptiveNetwork.h>
BOOL networkSwitchOff = NO;
Reachability *reach = [Reachability reachabilityForInternetConnection];
NetworkStatus status = [reach currentReachabilityStatus];
if(status==NotReachable){ //Reachability NotReachable
NSArray *supportedInterfaces = (__bridge_transfer id)CNCopySupportedInterfaces();
id info = nil;
NSString *ssid = nil;
for (NSString *networkInfo in supportedInterfaces) {
info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)networkInfo);
if (info && [info count])
break;
}
if (info) {
NSDictionary *dctySSID = (NSDictionary *)info;
//we can't get ssid if wifi is not connected
ssid = [dctySSID objectForKey:@"SSID"];
}
networkSwitchOff = (ssid!=nil);
}

pkamb
- 33,281
- 23
- 160
- 191

Shawn Wang
- 2,314
- 1
- 16
- 19