检查手机是否设置了代理
- (BOOL) checkProxySetting {
NSDictionary *proxySettings = (__bridge NSDictionary *)(CFNetworkCopySystemProxySettings());
NSArray *proxies = (__bridge NSArray *)(CFNetworkCopyProxiesForURL((__bridge CFURLRef _Nonnull)([NSURL URLWithString:@"https://www.baidu.com/"]), (__bridge CFDictionaryRef _Nonnull)(proxySettings)));
NSDictionary *settings = [proxies firstObject];
// NSLog(@"%@",proxySettings);
// NSLog(@"%@",proxies);
// NSLog(@"%@",settings);
// NSLog(@"%@",[settings objectForKey:(NSString *)kCFProxyHostNameKey]);
// NSLog(@"%@",[settings objectForKey:(NSString *)kCFProxyPortNumberKey]);
// NSLog(@"%@",[settings objectForKey:(NSString *)kCFProxyTypeKey]);
// kCFProxyTypeHTTPS kCFProxyTypeNone
if (![[settings objectForKey:(NSString *)kCFProxyTypeKey] isEqualToString:@"kCFProxyTypeNone"]){
//检测到抓包
// [[UIApplication sharedApplication].keyWindow wp_showHudWithText:nil detailText:@"当前网络不安全,请检查后再试" delay:kDelayTime];
UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"当前网络环境异常,请检查后再试" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alter show];
return YES;
}else {
return NO;
}
}
网友评论