Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IOS报摊后台疑难解答_Ios_Objective C_Push Notification_Background Process_Newsstand Kit - Fatal编程技术网

IOS报摊后台疑难解答

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

我正在启动一个报摊应用程序,首先我要测试所有的框架,看看谁在工作。我已经在前台下载了一个由通知触发的问题。但我不知道如何在后台下载,或者至少我错过了一些东西。。。以下是我添加到plist的内容:

该应用程序是针对IOS 5的。。。这是我的密码。。。当然,我还实现了
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
    
    }
    

我已经有了所需的背景模式-报摊内容,我的代码已经是这样了。我尝试打开应用程序,然后单击主页按钮,然后发送警报。我收到警报,但下载未启动。我尝试了ios7.0.4和5.1.1,结果仍然相同。它在前台工作,当我在锁屏上滑动通知HUD打开应用程序时也可以。还可能是什么,请帮帮我,我终于明白了!我还需要所需的后台模式-应用程序下载内容以响应推送通知