美文网首页
iOS检查是否设置了网络代理

iOS检查是否设置了网络代理

作者: Anrik | 来源:发表于2018-08-09 10:11 被阅读31次

    检查手机是否设置了代理

    - (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;
        }
    }
    

    相关文章

      网友评论

          本文标题:iOS检查是否设置了网络代理

          本文链接:https://www.haomeiwen.com/subject/aelqbftx.html