In my ExtensionDelegate I'm starting a URLSessionTask with following code:
func scheduleNextURLSessionTask() {
let backgroundConfigObject = URLSessionConfiguration.background(withIdentifier: "myIdentifier")
let backgroundSession = URLSession(configuration: backgroundConfigObject, delegate: self, delegateQueue: nil)
let retrieveTask = backgroundSession.dataTask(with: URL(string: "https://api.wedtec.net/cryptocoins/index.php?bitcoin&simple")!)
retrieveTask.resume()
}
My ExtensionDelegate implements URLSessionDataDelegate, of course. This runs always into an error. Means
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?)
Will be triggered will following error message:
URLSessionTask didCompleteWithError Optional(Error Domain=NSURLErrorDomain Code=-997 "Lost connection to background transfer service" UserInfo={NSErrorFailingURLKey=https://api.wedtec.net/cryptocoins/index.php?bitcoin&simple, NSErrorFailingURLStringKey=https://api.wedtec.net/cryptocoins/index.php?bitcoin&simple, NSLocalizedDescription=Lost connection to background transfer service})
Any Idea what could be wrong here? scheduleNextURLSessionTask is called from a background process (WKApplicationRefreshBackgroundTask).