Posts

Post not yet marked as solved
0 Replies
375 Views
func itemLoadCompletedWithPreprocessingResults(_ javaScriptPreprocessingResults: [String: Any]) { let configuration = URLSessionConfiguration.background(withIdentifier: "com.wdy.backgroundsession") configuration.sharedContainerIdentifier = "group.com.joe.WebSiteTranslator" let session = URLSession(configuration: configuration, delegate: self, delegateQueue: nil) var request = URLRequest(url: URL(string: "http://fanyi.sogou.com/reventondc/api/sogouTranslate")!) request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") request.httpMethod = "POST" let postString = params.compactMap({ (key, value) -> String in return "\(key)=\(value)" }).joined(separator: "&") request.httpBody = postString.data(using: .utf8) let _ = session.dataTask(with: request) self.doneWithResults(["newURL": ""]) }This is the error message I received2019-11-25 17:41:38.646931+0800 Extension[13136:457276] Task <A8690996-9E59-43DB-B8CB-24EEBD75BB5A>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-997 "Lost connection to background transfer service" UserInfo={NSErrorFailingURLStringKey=http://fanyi.sogou.com/reventondc/api/sogouTranslate, NSErrorFailingURLKey=http://fanyi.sogou.com/reventondc/api/sogouTranslate, _NSURLErrorRelatedURLSessionTaskErrorKey=( "BackgroundDataTask <A8690996-9E59-43DB-B8CB-24EEBD75BB5A>.<1>", "LocalDataTask <A8690996-9E59-43DB-B8CB-24EEBD75BB5A>.<1>"), _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundDataTask <A8690996-9E59-43DB-B8CB-24EEBD75BB5A>.<1>, NSLocalizedDescription=Lost connection to background transfer service} [-997]
Posted
by joewang.
Last updated
.