Background fetch and background transfers in iOS to download data (JSON) on bakcground

笑着哭i 提交于 2019-12-10 12:05:33

问题


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. 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).

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

  3. 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).


回答1:


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

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

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

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.



来源:https://stackoverflow.com/questions/23047412/background-fetch-and-background-transfers-in-ios-to-download-data-json-on-bakc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!