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:
andendBackgroundTask:
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...
精彩评论