iOS中的背景抓取和背景传输,以便在bakcground上下载数据(JSON) [英] Background fetch and background transfers in iOS to download data (JSON) on bakcground

查看:195
本文介绍了iOS中的背景抓取和背景传输,以便在bakcground上下载数据(JSON)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的应用程式升级至iOS 7,并想到尝试新的多重任务API。我计划使用后台抓取或静默推送通知,以保持我的内容uptodate。基本上是JSON值的集合。大部分文档/代码我通过下载视频或图像查看,我有以下问题...

I am in the process of upgrading one of my apps to iOS 7 and thought of trying out the new multitasking apis. I am planning to use Background Fetching or Silent push notifications to keep my content uptodate. Basically set of JSON values. Most of the documentation/code I looked through download videos or images and I have following questions...


  1. 如果我们使用Background获取或静默推送通知,我们需要使用单独的backgroundSessionConfiguration下载数据吗?或者我们可以通过使用现有的defaultSessionConfiguration来做到这一点吗? (因为我可以重用现有的方法,而不是为后台下载提供单独的方法)。

  1. If we use Background Fetching or Silent push notifications, do we need to download data using a separate backgroundSessionConfiguration ? Or can we do this by utilizing existing defaultSessionConfiguration ? (Because I can reuse the existing method rather than having a separate method for background downloads).

可以使用后台传输下载大量数据除了文件资源?

Is it possible to use background transfers to download large set of data other than file assets ?

由于我知道后台背景提取只允许大约1分钟完成任务,是否可以使用fetch延长这段时间? (我的意思是,如果我们在后台抓取请求中启动后台转移,应用程序执行它并完成该作业,或者以递增方式运行它,如暂停,并在应用程序再次唤醒时恢复)。

As I know background background fetch only allows about 1 minute to complete the task , is it possible to use a background transfer inside the fetch to extend that period ? ( I mean, if we start a background transfer inside that background fetch request does the app execute it and complete the job. Or does run it incrementally like pause it and resume it when the app is woken again).


推荐答案

NSUrlSession仅支持文件的后台抓取。这是您设计中的一个重要考虑因素。

NSUrlSession supports background fetching of Files only. That is an important consideration in your design.

1)是的,您需要为后台下载创建一个会话配置。

1) Yes, you need to create a session configuration for background downloads.

2)除非您将数据下载到文件中,否则请读取文件

2) Not unless you download the data to a file then read the file

3)如果您发现达到时间限制。虽然下载所需的时间通常不计算在内,只是您的处理时间。

3) Background fetch can also be done incrementally in chunks if you find you are hitting a time limit. Though the time it takes to download usually isn't counted, just your processing of it.

这篇关于iOS中的背景抓取和背景传输,以便在bakcground上下载数据(JSON)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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