简体   繁体   中英

Is there any solution to pause NSURLSessionTask when iPhone goes to sleep and resume when iPhone becomes active

I am performing some NSURLSessionTask. It takes nearly 10-15 seconds to complete the task.Everything goes well when iPhone is in active state.

The problem here is while performing the task, if iPhones goes to sleep mode then task will stop with an error saying "Network connection lost".

Is there any solution to continue/pause the task even in sleep mode. I tried many solutions which I found in stackoverflow, but that didnt help me.

Please help me out.

According to a response on Apple's forum , downloading on iMac is not possible when the device is in sleep mode. I believe a similar case is with the iPhone. I think your best option would be to use the Background Transfer Service (iOS 7) .Here's an example to help you.

The primary objective of the sleep mode is to save power.So in addition to keeping your app running in background, the device would have to perform an additional task of downloading files, which (I think) is in contrast with the objective.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM