Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continue uploading process in background IOS

Tags:

ios

dropbox

I was wondering if it was possible to continue the uploading of a file in the background. for example when the user puts the iPad in sleep, the uploading continues...

I asked this question in the dropbox forums as well since I am uploading to dropbox using the core API. This was the answer:

"Using the core API, uploading is entirely in the control of your app. You can request that the OS keep your app alive in the background, which it will allow for a maximum of 10 minutes before suspending your app. You can see more information here: https://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html If you use the new Sync API, this will all be done automatically by the API."

I am posting here because I didn't understand what they mean by 'request that the OS keep your app alive in the background'. Does this mean I have to request the ios wi a specific code, and it has nothing to do with dropbox, or it is a particular dropbox function?

like image 549
Alessandro Avatar asked Apr 03 '13 13:04

Alessandro


People also ask

How do I keep iOS apps active in the background?

For iOS Devices If Background refresh is greyed out in the ON position, go To Settings App - > General - > Background App Refresh - > Turn on the option for the system, and then you can turn on / off by app.

Will iOS terminate the app running in background after a specific time?

At the same time, didReceiveMemoryWarning is invoked for the app. At this point, so that your app continues to run properly, the OS begins terminating apps in the background to free some memory. Once all background apps are terminated, if your app still needs more memory, the OS terminates your app.

How do you stop apps from closing in background iOS?

Instead, just disable background refresh for such apps. To do this, open the Settings screen, tap General, and tap Background App Refresh. Disable background refresh for an app and it won't have permission to run in the background.


1 Answers

You need to ask the OS to keep the app running, it has nothing to do with Dropbox... When you start uploading, do this:

UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
    [[UIApplication sharedApplication] endBackgroundTask:bgTask];
}];

... and store the bgTask somewhere. Then when your upload completes or fails, do this:

[[UIApplication sharedApplication] endBackgroundTask:bgTask];

That will tell the OS to keep your app running because there's a background task running...

like image 115
jjv360 Avatar answered Sep 19 '22 13:09

jjv360