I'm working on an iPhone app that uses data stored remotely. The app is to be used by our client only (no app store) and I'm not allow to specify the app's context.
The only context I can tell you is that the app allows a code to be entered, and downloads the data related to that code.
Our client told us that some times we'll need to use the app on places were internet isn't accessible or too slow.
The solution that has been drawn is the following:
We'll try to download the data on a local FTP server, which is actually just a router sharing a directory with the code as its name, accessible by a known IP (e.g.,
ftp://192.168.1.1/some-path
).If it fails, it tries to download from the web server.
I've found an awesome library called FTPManager by Nico Kreipke. (click here for its GitHub)
Unfortunately, when the FTP address isn't available, it take about one minute to timeout and move to the second step.
Does anyone can help out on reducing this timeout? Maybe making a quick ping to the IP? If so, how to do it?
Thanks for your time,
Tiago
Some More Info
I've tried a solution inspired by the answer of Rauru Ferro. But unfortunately it didn't help. The code used for testing follows:
NSString *ftp = [NSString stringWithFormat:@"ftp://user:password@%@/sda1/%@", ip, code]; NSURL *url = [NSURL URLWithString:ftp]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0]; NSURLResponse *response = nil; NSError *error = nil; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
I've tried several timeout values, but to no avail. It always ends with a timeout error. However, the downloading code is able to download data from the router's shared directory (using the same credentials).