开发者

Should I use beginBackgroundTaskWithExpirationHandler: for all HTTP connections?

开发者 https://www.devze.com 2023-03-27 00:22 出处:网络
I am developing an iOS application that has the capability of uploading data to a remote endpoint.Because a good user experience would involve being able to leave the app to go do some other task whil

I am developing an iOS application that has the capability of uploading data to a remote endpoint. Because a good user experience would involve being able to leave the app to go do some other task while it is开发者_StackOverflow uploading, should I initiate all my uploads with the beginBackgroundTaskWithExpirationHandler: API?


Yes. That is consistent with one of the design patterns described in the application design guide:

Wrap any long-running critical tasks with beginBackgroundTaskWithExpirationHandler: and endBackgroundTask: calls. This protects those tasks in situations where your application is suddenly moved to the background.

Then in the expiration handler you can mark the upload as incomplete, and return to it in applicationDidBecomeActive:.


well, in my point of view, applicationDidBecomeActive: method won't allow you handle something special, such as network access, location service, blue tooth function and so on. But i'm not skill enough to prove it...

0

精彩评论

暂无评论...
验证码 换一张
取 消