I have an Xcode project built with cocoapods. It has only Objective C code. I wanted to integrate the core spotlight framework to provide native search functionality to my app. The app uses AFNetworking for all the Networking calls. However when I connect to the server using http protocol, I'm currently getting this error.
"desc __NSCFConstantString * @"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." 0x04d9d6ac
I do not have HTTPS protocol implemented on the server side, so its just http for now. The same codebase is working perfectly with Xcode 6.x and iOS 8.3 SDK. Any ideas what might be the reason? Is someone else facing a similar problem?
Below is the code snippet from my app.
NSMutableURLRequest *request = [serializer requestWithMethod:@"GET" URLString:url parameters:parameters error:nil];
AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
[RESTSessionManager sharedSession:profile];
NSDictionary *json =
[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
NSMutableArray* entries = json[@"entries"];
NSDictionary *content = [entries[0] objectForKey:@"content"];
NSDictionary *properties = [content objectForKey:@"properties"];
profile.repoUserName= [properties objectForKey:@"user_name"];
success(operation, responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSString *desc = [[error userInfo] objectForKey:@"NSLocalizedDescription"];
if( [desc isEqual:@"The network connection was lost."] || [desc isEqual:@"Could not connect to the server."] || [desc isEqual:@"The request timed out."])
offline();
else
failure(operation, error);
}];