mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
[WIP]
This commit is contained in:
@@ -1530,6 +1530,8 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//self.addBackgroundDownloadTask()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1664,7 +1666,21 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
|||||||
task.resume()
|
task.resume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func addBackgroundDownloadTask() {
|
||||||
|
let baseAppBundleId = Bundle.main.bundleIdentifier!
|
||||||
|
let session = self.urlSession(identifier: "\(baseAppBundleId).backroundSession")
|
||||||
|
|
||||||
|
var request = URLRequest(url: URL(string: "https://example.com/\(UInt64.random(in: 0 ... UInt64.max))")!)
|
||||||
|
request.httpMethod = "GET"
|
||||||
|
|
||||||
|
let task = session.downloadTask(with: request)
|
||||||
|
Logger.shared.log("App \(self.episodeId)", "adding download task \(String(describing: request.url))")
|
||||||
|
task.earliestBeginDate = Date(timeIntervalSinceNow: 30.0)
|
||||||
|
task.resume()
|
||||||
|
}
|
||||||
|
|
||||||
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
|
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
|
||||||
|
Logger.shared.log("App \(self.episodeId)", "completed download task \(String(describing: task.originalRequest?.url)) error: \(String(describing: error))")
|
||||||
if let response = task.response as? HTTPURLResponse {
|
if let response = task.response as? HTTPURLResponse {
|
||||||
if let originalRequest = task.originalRequest {
|
if let originalRequest = task.originalRequest {
|
||||||
if let requestResourceId = originalRequest.value(forHTTPHeaderField: "tresource") {
|
if let requestResourceId = originalRequest.value(forHTTPHeaderField: "tresource") {
|
||||||
|
|||||||
Reference in New Issue
Block a user