直接检查是否设置了代理即可
- (BOOL)checkProxySetting
{
NSDictionary*proxySettings = (__bridgeNSDictionary*) (CFNetworkCopySystemProxySettings());
NSArray*proxies = (__bridgeNSArray*)(CFNetworkCopyProxiesForURL((__bridgeCFURLRef_Nonnull)([NSURLURLWithString:@"https://www.baidu.com"]), (__bridgeCFDictionaryRef_Nonnull)(proxySettings)));
NSLog(@"\n%@",proxies);
NSDictionary*settings = proxies[0];
NSLog(@"%@",[settings objectForKey:(NSString *)kCFProxyHostNameKey]);
NSLog(@"%@",[settings objectForKey:(NSString *)kCFProxyPortNumberKey]);
NSLog(@"%@",[settings objectForKey:(NSString *)kCFProxyTypeKey]);
if([[settingsobjectForKey:(NSString*)kCFProxyTypeKey]isEqualToString:@"kCFProxyTypeNone"])
{
NSLog(@"没设置代理");
returnNO;
}
else
{
NSLog(@"设置了代理");
returnYES;
}
}