one of my iOS Apps uses NSURLSession
to connect to a web service and query some data. I have just added and released this feature and in most cases it seems to work without any problems. However a hand full of customer report, that they are not able to uses the feature when the devices is connected to the internet using a mobile network. Using the feature on a WiFi connection is no problem on the other hand.
The code is nothing special but just a simple NSURLReqeust
using NSURLSession
NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig delegate:self delegateQueue:[NSOperationQueue mainQueue]];
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:myServiceURL];
[request addValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setHTTPMethod:@"GET"];
[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error != nil) {
// Log error...
} else {
// Handle response...
}
}] resume];
When the users run the feature on a mobile connection the request failes with error code -1009
which is kCFURLErrorNotConnectedToInternet
. OK, so no internet connect. But the users report, that all other services/apps like E-Mail, Safari, WhatsApp, etc. work without any problem on the same connection.
Any idea what might be going on here? Right now I have no idea in what direction to search for the problem. In my tests everything works just fine, no matter what kind of connection is used. Many other users report, that the also have no problem using the feature on mobile connections.