Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tiltem

macrumors newbie
Original poster
Oct 18, 2010
25
0
I have an ipad app that has a download that takes about 30 min. If the device is plugged in it works fine, but if not the connection seems to get lost and the app stops after the ipad "sleeps" from inactivity. How can I keep it awake or keep the connection going while the device sleeps?

connection code:
Code:
// Create the request.
NSURLRequest *theRequest=[NSURLRequest requestWithURL:url
											  cachePolicy:NSURLRequestUseProtocolCachePolicy
										  timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
	if (theConnection) {
		// Create the NSMutableData to hold the received data.
		// receivedData is an instance variable declared elsewhere.
		[[NSFileManager defaultManager] createFileAtPath:filepath contents:nil attributes:nil];		
	} else {
		// Inform the user that the connection failed.
	
	}
}



- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    // release the connection, and the data object
   
	
	[connection release];
	
	
    // inform the user
    if (kDebugMode) NSLog(@"Connection failed! Error - %@ %@",
          [error localizedDescription],
          [[error userInfo] objectForKey:NSLocalizedFailureReasonErrorKey]);
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    NSFileHandle *file = [NSFileHandle fileHandleForUpdatingAtPath: filepath];
    [file seekToEndOfFile];
	progressView.progress = (float)[file offsetInFile]/(float)[response expectedContentLength];
	[file writeData: data];
    [file closeFile];	

}
 

tiltem

macrumors newbie
Original poster
Oct 18, 2010
25
0
Well really about 15-20 min. and only once. Then they have all the content about 1G.

Used:
Code:
	[UIApplication sharedApplication].idleTimerDisabled = YES;
to get around the issue, and reset after done.
If it could be shorter that would be great!
 
Last edited by a moderator:

cnstoll

macrumors 6502
Aug 29, 2010
254
0
Why don't you just include the data in the app bundle if they have to download it anyway?
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Well really about 15-20 min. and only once. Then they have all the content about 1G.
If it's only once, you should do as cnstoll suggested and just include the data in the app bundle. If you need to ensure they have the latest data, still include the base data in the app and then build a mechanism to download updated pieces only!
 

ulbador

macrumors 68000
Feb 11, 2010
1,554
0
That would ultimately piss me off and make me uninstall the application. Not only would my iPad be unavailable to me during the download, but the battery would be torn to pieces while the download is processing.

Incremental updates is the way to go.
 

tiltem

macrumors newbie
Original poster
Oct 18, 2010
25
0
client wants it to available for download over 3g network
 

ulbador

macrumors 68000
Feb 11, 2010
1,554
0
Imagine downloading 1GB over a 3G network...

haha.. no kidding. Talk about hammering by about 5 times, what, about 95% of people's 3G quotas? That should fly well when they run the app and get slammed with a huge increase in the monthly bill.
 

North Bronson

macrumors 6502
Oct 31, 2007
395
1
San José
client wants it to available for download over 3g network

So, if someone with 100 megs of free space downloads your app (expecting it to work), then finds out that it won't, their reaction will be -- what exactly? Understanding? Normal users don't want their apps to act like this. Putting it in the app description isn't good enough. For the user to need *fifty times* the extra space is just asking a lot.

I'm sorry your client is pushing for this. I would recommend explaining to your client that not only is this demand producing technical issues (the bug), but will also produce a less-than-optimal user experience; the result will be bad customer reviews and fewer downloads -- the 3G availability will be a non-issue.
 

MacBill

macrumors newbie
Dec 31, 2010
27
0
Western Montana
Set auto lock to NEVER, plug iPad into charger, then go get a snack, go bowling, take your girlfriend to a movie. I wish the iPad had a faster processor.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.