0
私がASIHTTPREQUESTを使用してスリープモードに移行すると、INAPPの購入をダウンロードする方法の問題を助けてくれる人がいるかと思いますが、アプリで購入してダウンロードする音楽ファイルしかし、ユーザがアルバムを購入して、例えばアルバムをダウンロードし始めた場合、彼の電話がスリープすると、そのダウンロードは停止する!!!コメント、を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;
}
[request setShouldContinueWhenAppEntersBackground:YES];を追加するにはどうすればよいですか?どのクラスでこのメソッドを利用できるようにするべきですか? –
@HashTechniq私は私の答えを編集しました! – CarlJ
"setShouldContinueWhenAppEntersBackground"というメソッドが上記のようにリストされていません!!!どうしましたか?? –