ios 常驻后台上传_揭秘ios中的后台上传下载

本文深入探讨了iOS系统中如何实现常驻后台的文件上传功能,解析了相关机制和技术要点。
摘要由CSDN通过智能技术生成

ios 常驻后台上传

What’s the general thought that comes to any iOS Developer’s mind when they think of background tasks?

任何iOS开发人员想到后台任务时会想到什么?

That’s right, you would immediately think of the above API in UIApplication to extend the time of your app to run on background in order to complete your uploads/downloads. But what if the download/upload size if huge, let’s say for 500MB for example, and you are on LTE/3G connection. Would this still work? The answer is that there is no guarantee that your upload/download would complete, it is highly probable that your app might be killed by the system due to various reasons(like memory pressure, battery etc.) in between.

没错,您会立即想到上述UIApplication中的API,以延长应用程序在后台运行的时间,从而完成上载/下载。 但是,如果下载/上传大小很大(例如,假设为500MB),而您正在LTE / 3G连接上,该怎么办? 这仍然有效吗? 答案是,不能保证您的上传/下载会完成,这很可能是由于介于两者之间的各种原因(例如内存压力,电池电量等)导致您的应用被系统杀死。

How do we guarantee that this works? Does iOS have a solution for the same?

我们如何保证这有效? iOS是否有相同的解决方案?

Image for post
Photo by Jake Young on Unsplash
杰克·杨( Jake Young)Unsplash

The answer is YES, NSURLSessionConfiguration provides APIs to help with uploads/download working smoothly when backgrounding the app. The uploads/downloads using this API will work even if your app is killed by the OS. They won’t work if you force kill the app. iOS basically passes the upload/download task to the system’s upload daemon thread if your app is killed and for this very reason, its important to save your file to a permanent location on device.

答案是肯定的,NSURLSessionConfiguration提供API来帮助在使应用程序后台运行时顺利进行上载/下载。 即使您的应用被操作系统杀死,使用此API进行的上传/下载也将起作用。 如果您强行杀死​​应用程序,它们将

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值