gpt4 book ai didi

IOS报亭后台故障排除

转载 作者:行者123 更新时间:2023-11-29 03:23:38 24 4
gpt4 key购买 nike

我正在启动一个报亭应用程序,首先我正在测试所有框架,看看谁的一切都有效。我已经下载了在前台时由通知触发的问题。但我不知道如何在后台下载,或者至少我丢失了一些东西......这是我添加到 plist 的内容: plist

该应用程序针对 IOS 5...这是我的代码...当然我还实现了 NKAssetDownload 的三个 URLConection 方法

    - (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 通知唤醒应用程序(将其滑开后),它有一个错误:read here and here (log in with your dev account) .如果您要测试的设备尚未更新,它应该可以在 iOS 5-6 上运行。

  • 您还需要 Info.plist 中的 key :Required background modes - newsstand-content

  • 最后,在您的代码中,我认为您应该对 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

    }

关于IOS报亭后台故障排除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20764967/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com