Forum Discussion

Jean-Baptiste D2's avatar
Jean-Baptiste D2
New member | Level 1
11 years ago

[DBRestClient] uploadFile: doesn't prevent my app from being killed in background

[Re-posting it here, since I think I posted it in the wrong category earlier, sorry for that]

 

Hello,

I'm using Dropbox SDK to upload a file after my app is awakened by iOS through a Silent Notification.

The problem is : The transfer begin but my app is killed by iOS before it can finish. I can see its progress when logging the output of restClient:uploadProgress: and it doesn't have the time to finish.

I thought that when making background downloads or uploads, if we used NSURLSession, iOS detects it and wait for it to finish. Do you guys use it in your SDK ?

Interesting facts :

- I don't have any problem when uploading the same file on iCloud with iCloudDocumentSync.

- The problem doesn't occur when the app is not killed before iOS awaken it with Silent Notifications. By killing, I don't mean closing it from the app switcher, but by terminating it with the "Stop" button from Xcode while it's in background (It's the best way I found in order to simulate the fact that sometimes iOS kill your app while it's in background (like after you played a game and iOS freed all the memory it could)).

- I tried to schedule the RunLoop to keep working for 2 minutes, but iOS still kills it.

- I'm on the main thread when I'm doing the upload.

- I didn't fire the UIBackgroundFetchResult completion handler before it was killed.

- The message iOS displays is Xcode devices :

Sep 20 16:32:20 Jbs-iPhone-5 assertiond[69] <Warning>: <BKNewProcess: 0x15662ea00; com.*********.********; pid: 374; hostpid: -1> has active assertions beyond permitted time:
{(
<BKProcessAssertion: 0x156522220> id: 57-6838B6CE-8BAA-4BFD-83C7-BCD5E475779D name: Background Content Fetching (23) process: <BKNewProcess: 0x15662ea00; com.********.*********; pid: 374; hostpid: -1> permittedBackgroundDuration: 30.000000 reason: backgroundContentFetching owner pid:57 preventSuspend preventThrottleDownUI preventIdleSleep preventSuspendOnSleep
)}

Then in my Device logs, I have this crash log :

Application Specific Information:
com.*********.********failed to scene-create after 19.73s (launch took 0.27s of total time limit 20.00s)

 

Thank you in advance, I really hope you'll be able to help me.

Jean-Baptiste

 

 

2 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    11 years ago

    [Thanks for reposting. The API development forum is the right one for anything API related. The "Bugs & Troubleshooting" forum is more about the Dropbox product itself. I've deleted your other post so we can consolidate here.]

    Anyway, the Dropbox iOS Core SDK doesn't use NSURLSession. It's a wrapper around the HTTP endpoints that uses NSURLRequest, so you'll need to configure any background functionality as necessary for your app in your app code. (The iOS Core SDK is open source though, so alternatively you could add the source directly and modify it as desired instead.) We don't we have any sample code for this in particular however.

    We'll consider this a feature request though. Also, I believe our new SwiftyDropbox library, for the Dropbox API v2, currently in preview, does use NSURLSession via AlamoFire. 

  • Jean-Baptiste D2's avatar
    Jean-Baptiste D2
    New member | Level 1
    11 years ago

    That's great! I'm gonna try these this WE!

    I'll let you know how it goes and which solution worked best for me.

    Thank you very much for your help :D

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!