appstore - iOS 6.4号更新版本以后 只能通过无线局域网访问 流量访问不到
PHPz
PHPz 2017-04-18 09:06:35
0
0
1002
/**
 *  Post请求
 *
 *  @param uri      <#uri description#>
 *  @param params   <#params description#>
 *  @param callback <#callback description#>
 */
- (void)execute:(NSString*) uri params:(NSArray *)params WithFunctionName:(NSString *) functionName WithServiceName:(NSString *) serviceName callback:(REQUEST_CALLBACK)callback{
    
    /*  封装Soap请求信息 */
    NSString *soapMsg=[SoapHelper arrayToDefaultSoapMessage:params methodName:functionName];
    
    /*  输出Soap拼接信息 */
    
    NSLog(@"----------------------------Soap拼接信息------------------------------");
    SoapLog(soapMsg);
    NSLog(@"----------------------------Soap拼接信息------------------------------");
    /*  实例化网络请求管理对象*/
    AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:API_BASE_URL]];
    
 
    /*  检测网络状态 */
    if (![self beforeExecute:manager]) {
        [InfoRemind errorWithStr:@"网络连接失败"];
        return;
    };
    
    /*  创建request请求  */
    NSString *urlStr = [NSString stringWithFormat:@"%@/Wcf/%@.svc", API_BASE_URL, serviceName];
    NSURL *url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
    
    /*  设置请求格式信息  */
    [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue:[NSString stringWithFormat:@"http://tempuri.org/%@/%@",[NSString stringWithFormat:@"I%@",serviceName],functionName] forHTTPHeaderField:@"SOAPAction"];
    NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)soapMsg.length];
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];

    [theRequest setTimeoutInterval:30];
    
    /*  创建请求操作  */
    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:theRequest];
//    NSLog(@"%f",operation.request.timeoutInterval);
    
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        if(callback != nil){
            callback([CommonResponse configResponseInfo:operation WithResponseObject:responseObject  WithError:nil WithResponseState:SUCCESSSTATE WithFunctionName:functionName]);
        }

    }failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%@",error);
        CommonResponse *commonResponse=[CommonResponse configResponseInfo:operation WithResponseObject:nil WithError:error WithResponseState:ERRORSTATE WithFunctionName:functionName];
                [self afterExecute:commonResponse];
                if (callback!=nil) {
                     callback(commonResponse);
                }
    }];
    /*请求操作放入请求队列中*/
    [manager.operationQueue addOperation:operation];
}


/**
 *  判断网络状况
 *
 *  @param manager AFHTTPRequestOperationManager
 *
 *  @return <#return value description#>
 */
- (BOOL)beforeExecute:(AFHTTPRequestOperationManager*)manager {
    __block int Reachability;
    NSOperationQueue *operationQueue = manager.operationQueue;
    [manager.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {

        switch (status) {
            case AFNetworkReachabilityStatusReachableViaWWAN:
            case AFNetworkReachabilityStatusReachableViaWiFi:
                [operationQueue setSuspended:NO];
                Reachability=1;
                break;
            case AFNetworkReachabilityStatusNotReachable:
                Reachability=0;
            default:
                [operationQueue setSuspended:YES];
                break;
        }
    }];
    [manager.reachabilityManager startMonitoring];
    return true;
}

/**
 *  网络失败提示
 *
 *  @param response CommonResponse
 *
 *  @return 操作成功结果
 */
- (BOOL) afterExecute:(CommonResponse *) response {
    if (response.error == nil) {
        return TRUE;
    }
    if ([response.error code] == NSURLErrorNotConnectedToInternet) {
        [InfoRemind errorWithStr:@"网络不给力"];
        return FALSE;
    }
    [InfoRemind errorWithStr:@"服务器故障,请稍微再试"];
    return true;
}

但是如果使用数据流量的话,就会提示网络不给力,使用无线局域网就没有问题。
而且通过电脑装在我手机上的版本,可以使用流量,无线,但是从App Store 下载下来的只能通过无线去访问
疑问:
1.是不是苹果公司的上传审核都是通过无线去审核的。
2.我的项目用的还是AFN2.x的,苹果并没有拒绝,我看了相关资料2.x也是满足ipv6
那为什么的我的项目会通过审核呢。
补充:

1.有人说我的地址是内网地址,这点我确认了下,是我们的公司的外网的地址,也不是IP,也是有域名的。不存在内网这种可能
2.我们公司的域名前面没有www ,以前的话是没问题的。不知道有没有关系
PHPz
PHPz

学习是最好的投资!

Antworte allen(0)
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!