Bug 43204 - DidFinishEventsForBackgroundSession doesn't execute when doing background transfers on iOS
Summary: DidFinishEventsForBackgroundSession doesn't execute when doing background tra...
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.8 (tvOS / C7)
Hardware: PC Mac OS
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Alex Soto [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2016-08-09 21:54 UTC by Nick Spagnola
Modified: 2016-09-09 11:44 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Nick Spagnola 2016-08-09 21:54:13 UTC
When doing background transfers on iOS, `DidFinishEventsForBackgroundSession` doesn't appear to ever fire. Brandon Minnick  followed the below tutorial & sample app, and only `DidCompleteWithError` fires when the download completes; he even checked that `NSError==null`, which is true, which indicates that the download was successful.

The below StackOverflow link seems to collaborate his findings.

Tutorial:
https://developer.xamarin.com/guides/ios/application_fundamentals/backgrounding/part_4_ios_backgrounding_walkthroughs/background_transfer_walkthrough/

Sample App:
https://github.com/xamarin/monotouch-samples/tree/master/SimpleBackgroundTransfer

StackOverflow
http://stackoverflow.com/questions/25877984/xamarin-ios-background-upload-task-ios-7-didfinisheventsforbackgroundsession
Comment 1 Alex Soto [MSFT] 2016-08-09 23:44:20 UTC
Hello Nick

It seems that we are not alone in this boat, seems to happen also in ObjC
http://stackoverflow.com/questions/32676352/urlsessiondidfinisheventsforbackgroundurlsession-not-calling-objective-c

The above question provides some good findings:

These delegate methods won't get called if:

* The app is already running when the tasks finish;
* The app was terminated by double-tapping on the device's home button and manually killing it; or
* If you fail to start a background NSURLSession with the same identifier.

Also there are some comments that this won't work in the simulator, that it will just fire on device.

Nick do you mind testing if the above answers this? I can check later if you can't, since you guys have a workaround this is a little low priority now vs iOS 10 tasks :)
Comment 2 Vincent Dondain [MSFT] 2016-09-09 11:44:14 UTC
Sounds to me like Alex answered the question.

@Nick, please try again with (a) recent betas of Xamarin.iOS and (b) Xcode8 GM.

I'm closing this issue but if you're still experiencing this, feel free to re-open the bug.