From 56aa9e2ea1e5e6236b588e37223a78539f7c9477 Mon Sep 17 00:00:00 2001 From: Chris Hamons Date: Tue, 3 Nov 2020 09:42:43 -0600 Subject: [PATCH] Correct SimpleBackgroundTransfer sample to export optional protocol selectors (#410) - Fixes https://github.com/xamarin/ios-samples/issues/406 - Optional protocol methods must export if you use IFoo instead of Foo base class --- .../SimpleBackgroundTransferViewController.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SimpleBackgroundTransfer/SimpleBackgroundTransfer/SimpleBackgroundTransferViewController.cs b/SimpleBackgroundTransfer/SimpleBackgroundTransfer/SimpleBackgroundTransferViewController.cs index cfcc92983..5abeb3b54 100644 --- a/SimpleBackgroundTransfer/SimpleBackgroundTransfer/SimpleBackgroundTransferViewController.cs +++ b/SimpleBackgroundTransfer/SimpleBackgroundTransfer/SimpleBackgroundTransferViewController.cs @@ -79,6 +79,7 @@ public UrlSessionDelegate (SimpleBackgroundTransferViewController controller) this.controller = controller; } + [Export ("URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:")] public void DidWriteData (NSUrlSession session, NSUrlSessionDownloadTask downloadTask, long bytesWritten, long totalBytesWritten, long totalBytesExpectedToWrite) { Console.WriteLine ("Set Progress"); @@ -121,6 +122,7 @@ public void DidFinishDownloading (NSUrlSession session, NSUrlSessionDownloadTask } } + [Export ("URLSession:task:didCompleteWithError:")] public void DidCompleteWithError (NSUrlSession session, NSUrlSessionTask task, NSError error) { Console.WriteLine ("DidComplete"); @@ -137,11 +139,13 @@ public void DidCompleteWithError (NSUrlSession session, NSUrlSessionTask task, N controller.downloadTask = null; } + [Export ("URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:")] public void DidResume (NSUrlSession session, NSUrlSessionDownloadTask downloadTask, long resumeFileOffset, long expectedTotalBytes) { Console.WriteLine ("DidResume"); } + [Export ("URLSessionDidFinishEventsForBackgroundURLSession:")] public void DidFinishEventsForBackgroundSession (NSUrlSession session) { using (AppDelegate appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate) {