Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to cancel an NKAssetDownload?

I have a magazine reader on the App Store. I'm implementing NewsstandKit features at the moment.

My app has this download workflow where users can cancel current downloads at anytime.

I want to enable users to purchase an in-app product and begin that download as a newsstand background download (magazines include multimedia so they are kind of big files) but still preserve that option of they had on previous versions where they could cancel downloads.

Is it possible to achieve this with NKAssetDownload? Or should I remove the whole NKIssue instead?

like image 363
Pacu Avatar asked Dec 27 '22 08:12

Pacu


2 Answers

If you remove an issue, corresponding downloads will be canceled.

NKIssue *issue = [[NKLibrary sharedLibrary] issueWithName:editionName]; 
if (issue)
    [[NKLibrary sharedLibrary] removeIssue:issue];
like image 98
Gustavo Avatar answered Feb 08 '23 12:02

Gustavo


You should use this method on the asset :

- (void)removeIssue:(NKIssue *)issue

// Remove asset
[[NKLibrary sharedLibrary] removeIssue:[[NKLibrary sharedLibrary]
                           issueWithName:self.issues[indexPath.row][@"Name"]]];

Description from Apple documentation :
Removes the specified issue from the newsstand content library. When an issue is removed, any data at the file-system location identified by the issue’s content URL (accessed through the contentURL property of NKIssue) is deleted from disk. If you have issue content elsewhere in the application sandbox, it’s your responsibility to clean it up. Calling this method also cancels any asset downloads for that issue that are underway.

Source : http://developer.apple.com/library/ios/documentation/StoreKit/Reference/NKLibrary_Class/NKLibrary/NKLibrary.html#//apple_ref/doc/uid/TP40010835-CH2-SW2

like image 36
dulgan Avatar answered Feb 08 '23 13:02

dulgan