-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hi! Thanks for the blog post and code – it really helped demystify a bunch of things for me.
Since the URLSession is defined as a lazy var, my understanding is that the URLSession is not created until the first access of this property. Therefore, the delegate is not attached to the background URLSession until the first time the property is accessed.
What does this mean for restoration from a terminated state? When the OS relaunches the app, there is presumably no link between the background download process and the delegate. My hunch is that you need to explicitly access the session property to establish that link so that the background process can call the delegate's methods. So, something like this for example:
func saveAppPreviewCompletionHandler(_ appPreviewCompletionHandler: @escaping (() -> Void)) {
let _ = self.session
self.appPreviewCompletionHandler = appPreviewCompletionHandler
}I was wondering if you might have explored this possibility before I go down the rabbit hole myself.
Cheers!