LostBalloon
LostBalloon

Reputation: 1727

Xamarin iOS background upload task (iOS 7) - DidFinishEventsForBackgroundSession

From what I understand from the documentation DidFinishEventsForBackgroundSession is supposed to be called when the task completes (the transfer completes)

I have a progress bar that updates based on the totalBytesSent / totalBytesExpectedToSend, allowing me to tell when it's supposed to be done.

I've also followed the instructions (in regard to uploads) in the walkthrough from the Xamarin at the following link:

background transfer walkthrough

I put a breakpoint inside the DidFinishEventsForBackgroundSession and it never seemed to get called.

Edit: What is the proper way to detect completion of tasks (or being notified, when in background, for throwing a notification so the user can know it's done)

Upvotes: 2

Views: 841

Answers (1)

DannyC
DannyC

Reputation: 411

Was having the same issue until I switched to using didCompleteWithError. Reading Apple's documentation suggests didCompleteWithError tells the delegate that the task finished. This is what I have been using and working like a charm. You can check the error parameter to see if returned an error or if it's null.

https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSessionTaskDelegate_protocol/index.html#//apple_ref/occ/intfm/NSURLSessionTaskDelegate/URLSession:task:didCompleteWithError:

Upvotes: 1

Related Questions