如何在下图中获得Apps Using WLAN & Cellular Setting
设置状态?
如何查看我的应用程序的状态(无,WLAN,WLAN和移动电话),以便我可以显示警告以提醒用户打开此开关〜
答案 0 :(得分:1)
我终于找到了解决方案〜
:d
当Reachability为NotReachable
时,有两种情况,
Apps Using WLAN & Cellular Setting
关闭如果我们可以获得当前wifi的SSID,我们可以判断wifi已连接且网络开关已关闭〜
#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);
}