AFNetworking 2 and background tasks

我只是一个虾纸丫 提交于 2019-12-14 02:39:51

问题


I have a question about AFNetworking 2 and background downloads/uploads thanks to the new iOS7 NSURLSession background requests

Is this automatically handled by my AFHTTPRequestOperationManager ? Does it automatically set my requests'session to background mode? I saw that the AFURLSessionManager Has a setDidFinishEventsForBackgroundURLSessionBlock Method but I wonder if everything is automatic?

If my app is killed or suspended, will requests keep on going? How can I get a callback when my app is relaunched?

Thanks a lot for your help!


回答1:


AFHTTPRequestOperationManager uses the old NSURLConnection so that doesn't facilitate background downloading.

AFURLSessionManager uses NSURLSession under the hood so that does. I think you still need to configure the NSURLSession appropriately.

"The NSURLSession class supports background transfers while your app is suspended. Background transfers are provided only by sessions created using a background session configuration object (as returned by a call to backgroundSessionConfiguration:)."

Suggested reading:URL Loading System



来源:https://stackoverflow.com/questions/21476669/afnetworking-2-and-background-tasks

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