I'm starting a newsstand application and first I'm testing all the framework to see who everything works. I already downloaded an issue triggered by a notification when in foreground. but I don't know how to download in background, or at least I'm missing something... Here is the stuff I added to plist:
The app is targeted for IOS 5... here is my code... of course I also implemented the three URLConection methods of NKAssetDownload
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([launchOptions objectForKey:UIApplicationLaunchOptionsNewsstandDownloadsKey] || [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
NKLibrary *nkLib = [NKLibrary sharedLibrary];
for(NKAssetDownload *asset in [nkLib downloadingAssets]) {
[asset downloadWithDelegate:self];
}
}else{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeNewsstandContentAvailability
)];
}
[[NSUserDefaults standardUserDefaults]setBool: YES forKey:@"NKDontThrottleNewsstandContentNotifications"];
[[NSUserDefaults standardUserDefaults] synchronize];
return YES;
}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
NSLog(@"didReceiveRemoteNotification");
if (userInfo) {
NKIssue *issue4 = [[NKLibrary sharedLibrary] issueWithName:@"01_Primera"];
if (!issue4) {
issue4= [[NKLibrary sharedLibrary] addIssueWithName:@"01_Primera" date:[NSDate date]];
}
if([issue4 status]==NKIssueContentStatusNone) {
NSURL *downloadURL = [NSURL URLWithString:@"http://www.viggiosoft.com/media/data/blog/newsstand/magazine-4.pdf"];
NSURLRequest *req = [NSURLRequest requestWithURL:downloadURL];
NKAssetDownload *assetDownload = [issue4 addAssetWithRequest:req];
[assetDownload downloadWithDelegate:self];
}
}
}
What am I missing, and also do I have extra unnecessary code? please help.