0
我不知道是否有人可以幫我解決問題如何保持INAPP購買下載當設備進入睡眠模式使用ASIHTTPREQUEST時,我做了一個應用程序,其中包含一些音樂文件在應用程序中購買和下載,但是如果用戶購買並開始下載相冊,例如,如果他的手機在睡覺,它會停止下載! 與欣賞方面的任何意見,使用ASIHTTPRequest
-(void) downloadAlbum:(NSNumber *)Albumid {
//NSLog(@"%@",Albumid);
//myTable.scrollEnabled = NO;
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
if (CurrentSongID<=CurrentAlbumCount) {
if (isDownload==FALSE) {
Reachability* internetReach = [[Reachability reachabilityForInternetConnection] retain];
[internetReach startNotifier];
NetworkStatus netStatus = [internetReach currentReachabilityStatus];
switch (netStatus)
{
case NotReachable:
{ UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"Top 10" message: @"Check Internet Connectivity" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[someError show];
[someError release];
break;
}
case ReachableViaWWAN:
{
}
case ReachableViaWiFi:
{ NSString *DestinationFileName= [self FileNameGetter:Albumid FileID:CurrentSongID ];
NSString * URL=[NSString stringWithFormat: @"http://core-4.doubleu.mobi/cdownload/%@/%d.mp3",[self AlbumNameGetter:Albumid],CurrentSongID];
isDownload=TRUE;
progressIndicator.hidden=FALSE;
DownloadedFileName.hidden=FALSE;
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"Albums" ofType:@"plist"];
contentArray=[NSMutableArray arrayWithContentsOfFile:plistPath];
//NSLog(@"%@",contentArray);
DownloadedFileName.text=[NSString stringWithFormat:@"%d/%d",CurrentSongID ,CurrentAlbumCount];//[CurrentAlbum count]];
if (!networkQueue) {
networkQueue = [[ASINetworkQueue alloc] init];
}
failed = NO;
[networkQueue setDownloadProgressDelegate:progressIndicator];
[networkQueue setRequestDidFinishSelector:@selector(nextDownload)];
[networkQueue setShowAccurateProgress:YES];
[networkQueue setDelegate:self];
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:URL]];
[request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"]
stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mp3",[self FileNameGetter:Albumid FileID:CurrentSongID ]]]];
[networkQueue addOperation:request];
[networkQueue go];
break;
}
}
}
else {
UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"Top 10" message: @"Please wait Until download Completed" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[someError show];
[someError release];
}
}
else {
//NSString *DestinationFileName= [self FileNameGetter:NSCurrentAlbumID FileID:CurrentSongID ];
//myTable.scrollEnabled = YES;
switch (CurrentAlbumIDd) {
//to be modified
case 1:
{
//NSString *DestinationFileName= [self FileNameGetter:NSCurrentAlbumID FileID:CurrentSongID ];
UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"فضل شاكر" message:[NSString stringWithFormat:@"Download بياع القلوب Completed"] delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[someError show];
[someError release];
//[Album1 setTag:Album1.tag*100];
downloaded1 = TRUE;
available1=1;
break;}
case 2:
{
UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"فضل شاكر" message:[NSString stringWithFormat:@"Download الحب القديم Completed"] delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[someError show];
[someError release];
// [Album2 setTag:Album2.tag*100];
downloaded2 = TRUE;
available2=1;
break;
}
case 3:
{
UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"فضل شاكر" message:[NSString stringWithFormat:@"Download حبك خيال Completed"] delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[someError show];
[someError release];
// [Album3 setTag:Album3.tag*100];
downloaded3 = TRUE;
available3=1;
break;
}
如何添加方法[請求setShouldContinueWhenAppEntersBackground:YES]; ???我應該添加哪個類來使此方法可用? – 2012-04-18 15:17:50
@HashTechniq我編輯了我的答案! – CarlJ 2012-04-19 07:38:00
花花公子的方法「setShouldContinueWhenAppEntersBackground」沒有列出你上面提到的!怎麼了?? – 2012-05-03 18:16:45