[英]Is there any solution to pause NSURLSessionTask when iPhone goes to sleep and resume when iPhone becomes active
I am performing some NSURLSessionTask. 我正在执行一些NSURLSessionTask。 It takes nearly 10-15 seconds to complete the task.Everything goes well when iPhone is in active state.
完成任务大约需要10-15秒。当iPhone处于活动状态时,一切都会顺利进行。
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". 这里的问题是在执行任务时,如果iPhone进入睡眠模式,则任务将停止,并显示一条错误消息“网络连接丢失”。
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.
我尝试了许多在stackoverflow中找到的解决方案,但这并没有帮助我。
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. 根据苹果论坛上的回复,当设备处于睡眠模式时,无法在iMac上下载。 I believe a similar case is with the iPhone.
我相信iPhone也有类似情况。 I think your best option would be to use the Background Transfer Service (iOS 7) .Here's an example to help you.
我认为您最好的选择是使用Background Transfer Service(iOS 7)。以下是一个可以帮助您的示例 。
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. 睡眠模式的主要目的是节省电量,因此除了使您的应用程序在后台运行之外,该设备还必须执行下载文件的其他任务,这与我的目标形成了鲜明对比。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.