Hi,
I try to implement the BackgroundTask handling from this WWDC2022 video: https://developer.apple.com/videos/play/wwdc2022/10142
But it always crashes with this error: *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Completion handler blocks are not supported in background sessions. Use a delegate instead.'
So, is the video updated or is this a bug?
watchOS is a bit tricky but on iOS the rules are very clear: You can’t use the ‘convenience’ methods on a URLSession
background session. That includes:
-
The methods that create a task with a completion handler, for example,
dataTask(with:completionHandler:)
-
The Swift async methods
The code at 9:55 of that presentation does the latter, and thus is just wrong )-: Sorry about that.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"