I work on an iOS/iPadOS application which users rely on for life-and-death work, and our users need to be able to have as much information available offline as possible. Some of our clients have multiple .mmpk maps that they need to trust are getting downloaded no matter what. Using the normal path for downloading an .mmpk file using the Esri SDK triggers a type of download that will be terminated if the app crashes, is killed, or is for some reason unloaded from memory by the OS. Since these downloads can be fairly large, there is an increased (and most certainly non-zero) chance that any of these things might happen, forcing the user to have to start the large and long download over again.
As a result, I set up a background session downloader in our codebase to set up an OS-level background download. This makes the download live independently of the app life cycle, allows for the resuming of a past download when the app restarts, and also allows for the app to be loaded back into memory from the app delegate if the download finishes while the app is not currently loaded into memory.
I have everything set up for it except one part: authentication. When `urlSession(_:didReceive:completionHandler
` is called by the URLSession, I have no idea what to do with the challenge. All our other Esri interactions are mediated through the Esri SDK, and so they are authenticated that way. We have a type that conforms to `ArcGISAuthenticationChallengeHandler` and I feel like I *should* be able to use that here, but I don't see a way to do it, because its primary method (`handleArcGISAuthenticationChallenge(_:)`) expects a type specific to Esri (`ArcGIS.ArcGISAuthenticationChallenge`) which I don't have an instance of in that URLSessionDelegate method.
So, is there a way I can repurpose/reuse the credentials we employed in our `ArcGISAuthenticationChallengeHandler` type to authenticate this background download?