I want to makes App can download file while entered background using Alamofire 5
But I can only found a older document for how to Alamofire's background download
So, I create a URLsession
lazy var AFSession: Session = {
let rootQueue = DispatchQueue(label: "org.alamofire.sessionManager.rootQueue")
let delegateQueue = OperationQueue()
delegateQueue.maxConcurrentOperationCount = 1
delegateQueue.underlyingQueue = rootQueue
delegateQueue.name = "app.name"
sessionConfig.isDiscretionary = true
let sessionDelegate = SessionDelegate.init(fileManager: FileManager.default)
URLSession.init(configutation: URLSessionConfiguration.background(withIdentifier: "app.name"), delegate: SessionDelegate(), delegateQueue: delegateQueue)
return Session.init(session: urlSession, delegate: SessionDelegate(), rootQueue: rootQueue)
}()
let request = AFSession.download(...){...}
So that the apps can continue download files when entered background I think
but it occurs a runtime error because of Alamofire's precondition checking
how to initialize the session on Alamofire 5 ?.. sorry about this question.. I can't found documents for alamofire 5 on Googles...
At least can use the session class to download files
Just code raises "Precondition failed" on precondition method because of initializing
Alamofire version: 5.0.0.beta.1'
Xcode version:10.1 (10B61)
Swift version:4.1
Platform(s) running Alamofire:iOS
macOS version running Xcode:Mojave
ℹ Please link to or upload a project we can download that reproduces the issue.
Hi @Minsoo-kim92,
Unfortunately, background sessions are not very well supported in Alamofire 5 as of yet. This is something we'll be looking to improve in future versions of AF 5.x. As of right now, our recommendation for using background sessions would be to either subclass the SessionDelegate and avoid using the top-level closure APIs on Request, or to simply use URLSession directly. The closure-based APIs do not capture state between launches, which is what is needed when using background sessions.
Hopefully that helps clear things up a bit. Best of luck. 🍻
Thank you for your reply
@Minsoo-kim92 Is Alamofire supporting background downloads now?
@SrikanthVelaga
Actually I'm using AWS SDK now, I don't using Alamofire background task now
Is this feature implemented yet?