In <= iOS 8 is OK. But iOS 9, i get error

1.9k Views Asked by At

I get error:

Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSErrorFailingURLStringKey=, NSErrorFailingURLKey=, NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x15d275b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "unsupported URL" UserInfo={NSErrorFailingURLKey=, NSErrorFailingURLStringKey=, NSLocalizedDescription=unsupported URL}}}

My code:

AFHTTPClient *httpClient = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:strUrl]];
[httpClient setParameterEncoding:AFFormURLParameterEncoding];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:nil parameters:info];
[request setTimeoutInterval:TIMEOUT_INTERVAL];

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
[operation  setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

    [self.delegate requestSuccess:[NSNumber numberWithInt:REQUEST_TYPE_LOGIN] result:[operation responseString]];


} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    [self.delegate requesFailed:[NSNumber numberWithInt:REQUEST_TYPE_LOGIN] result:[operation responseString]];
}

Any ideas for help me?

1

There are 1 best solutions below

4
Stefan On

In iOS 9 the default is to only allow https. You can opt out by adding keys to Info.plist : https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/