IOS报摊后台疑难解答
我正在启动一个报摊应用程序,首先我要测试所有的框架,看看谁在工作。我已经在前台下载了一个由通知触发的问题。但我不知道如何在后台下载,或者至少我错过了一些东西。。。以下是我添加到plist的内容: 该应用程序是针对IOS 5的。。。这是我的密码。。。当然,我还实现了IOS报摊后台疑难解答,ios,objective-c,push-notification,background-process,newsstand-kit,Ios,Objective C,Push Notification,Background Process,Newsstand Kit,我正在启动一个报摊应用程序,首先我要测试所有的框架,看看谁在工作。我已经在前台下载了一个由通知触发的问题。但我不知道如何在后台下载,或者至少我错过了一些东西。。。以下是我添加到plist的内容: 该应用程序是针对IOS 5的。。。这是我的密码。。。当然,我还实现了NKAssetDownload - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)la
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];
}
}
}
我遗漏了什么,我还有额外的不必要的代码吗?请帮忙。- 如果您正在测试用一个内容可用的通知唤醒应用程序(在刷走它之后):iOS7上的1,那么它有一个bug:。 如果您有一台尚未更新的设备要测试,它应该可以在iOS 5-6上运行
- 您还需要Info.plist中的密钥:
- 最后,在您的代码中,我认为您应该在didFinishLaunchingWithOptions中进行一些更改:
if ([launchOptions objectForKey:UIApplicationLaunchOptionsNewsstandDownloadsKey] || [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) { [self handleNotification:launchOptions]; } //...other code... //This code can be the same as with didReceiveRemoveNotification -(void) handleNotification:(NSDictionary*)userInfo{ //check userInfo for "content-available" key //if there is content-available:1 check for an issue_id/content_id in the rest of the notification payload (userInfo), and download the issue }