简体   繁体   English

ios:应用处于后台或挂起状态时下载大文件

[英]ios: Download large file when app is in background or suspended state

I have got a vendor app. 我有一个供应商应用程序。 The app needs to download a file containing products data on receiving push notification wether app is in background, suspended or terminated state. 该应用程序处于后台,暂停或终止状态时,应用程序需要在接收到推送通知时下载包含产品数据的文件。 Then the file needs to be dumped in coredata for further usage. 然后,需要将文件转储到coredata中以备进一步使用。

What's the best practice for achieving the above functionality? 实现上述功能的最佳实践是什么?

I have downloaded a file using urlSessionDownloadTask, and also dumped it in the coredata. 我已经使用urlSessionDownloadTask下载了一个文件,并将其转储到coredata中。 But that doesn't work when app is in suspended state. 但是,当应用处于暂停状态时,这是行不通的。

Any help. 任何帮助。

If you have to trigger a download in background, use this: https://developer.apple.com/documentation/foundation/url_loading_system/downloading_files_in_the_background 如果您必须在后台触发下载,请使用以下命令: https : //developer.apple.com/documentation/foundation/url_loading_system/downloading_files_in_the_background

However, because you need to handle notifications with an extension I suppose, you will have a hard time accessing your database from it. 但是,由于您需要使用扩展名来处理通知,因此很难从数据库访问数据库。 It's not recommended. 不推荐。 But it's possible by connecting to your database for using Core data the same way you do it in your main app. 但是有可能通过连接数据库来使用Core数据的方式与在主应用程序中进行操作的方式相同。 The only big drawback is that you won't be able to get core data context changes when you save your file in Costa. 唯一的大缺点是,将文件保存在Costa中时,您将无法获得核心数据上下文更改。 One way is to use a fetch with a repeat timer on your main app 一种方法是在主应用程序上使用带有重复计时器的访存

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使应用处于暂停状态,如何在ios中运行后台服务 - How to run Background service in ios even when app is in suspended state iOS-在应用处于暂停状态时运行后台进程 - iOS - Run background process while app is in suspended state 当iOS应用处于暂停状态时,如何处理SignificantLocation更改? - How to handle SignificantLocation change when an iOS app is in suspended state? 为什么我的iOS应用程序在后台立即暂停 - Why is my iOS app suspended instantly when in background 如果应用在暂停状态下可以运行,是否需要iOS后台模式? - is iOS background mode needed if app works when suspended? 当应用程序在iOS中没有报亭时处于不活动状态时,在后台下载文件 - Download file in background when app is inactive without newsstand in iOS 应用程序从暂停状态变为活动状态时的网络活动指示器(iOS) - Network activity indicator when app goes from suspended state to active state (iOS) iOS - 当应用程序未运行(应用程序处于挂起状态)时将纬度和经度发送到服务器 - iOS - Sending Latitude and Longitude to Server when app is not running (app is in suspended state) 用于下载任务的NSURLsession后台传输服务,即使在App暂停的情况下也可以使用吗? - NSURLsession background transfer service for download task, can it work even when App is suspended? 当应用程序进入暂停状态时取消本地通知。(从后台删除) - Cancel Local Notification When app goes to Suspended state.(removed from background)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM