在后台下载多个文件(仅适用于iOS 7) [英] Download several files in background (iOS 7 only)

查看:179
本文介绍了在后台下载多个文件(仅适用于iOS 7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个仅在iOS 7上运行的播客应用程序,它具有允许在后台模式下同步和下载最新剧集的功能。

I'm currently developing a podcast application which will run only on iOS 7, and it has a feature that allows to synchronize and download recent episodes in background mode.

所以很明显,同步,我实现了
应用程序:performFetchWithCompletionHandler
方法和调用同步方法,当同步完成后,我使用 UIBackgroundFetchResultNewData 调用completionHandler,或者如果失败,我调用 UIBackgroundFetchResultFailed 。但是,当我运行下载管理器开始下载所有新剧集可能需要很长时间,取决于网络质量和文件大小,背景模式在某些时候冻结,并暂停最近的下载。

So it's clear with Synchronization, I implemented the application:performFetchWithCompletionHandler method and call the sync method in it, and when the sync is done I call completionHandler with UIBackgroundFetchResultNewData, or if it fails I call UIBackgroundFetchResultFailed. But when I run the download manager to start downloading all new episodes it can takes very long, depends on the network quality and file sizes, and the background mode just freezes in some point and suspend the recent download.

如何正确设计后台下载?

How the background downloading should be designed correctly?

或者也可能有一些链接到教程,

Or maybe some link to tutorial which describes properly about the downloading files on background.

推荐答案

下载大量文件时,我观察到同样的行为。

I'm observing the same behavior when downloading a lot of files.

当您的应用程序被暂停时,将所有下载任务添加到后台会话中时,看起来效果会更好,而不是每次完成并调用委托后添加新的下载任务。

It looks like it performs better, when you add all the downloads tasks to the background session when your app gets suspended, than to add a new download task every time one has finished and calls your delegate.

另一个选项是使用NewsstandKit。背景下载运行非常顺利,但您有一些限制,如24小时阈值,您的应用程序将被隐藏在报摊中。

An other option would be to use the NewsstandKit. The background download runs very smooth but you have some restrictions like the 24h threshold and your app will be hidden in the newsstand.

这篇关于在后台下载多个文件(仅适用于iOS 7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆