Moya: Performing an URLSessionUploadTask in background?

Created on 18 Jun 2017  路  7Comments  路  Source: Moya/Moya

Hello,

Is it possible using Moya to perform an URLSessionUploadTask in background to send for example image even if the user return to home?

Thanks in advance!

question

Most helpful comment

@yunustek At the moment it looks like the way you can solve it by switching from Moya/Alamofire to native URLSession.

All 7 comments

Hey @XavierDK. You can create your own Manager and pass it to the MoyaProvider:

let configuration = URLSessionConfiguration.background(withIdentifier: "com.example.app.background")
let manager = Manager(configuration: configuration)

Let us know if it helps!

Edit: Also, see how the default Manager is created here.

Thank you @sunshinejr! It's exactly what I was searching about.

Glad it worked! 馃帀

It seems this is not possible any more with the latest version since it depends on Alamofire 5 which disabled background sessions: https://github.com/Alamofire/Alamofire/commit/1d5411cdde887cb9c8d282239fa4a44d42bd5e9f

Any other solutions?

How can I do that? As @teameh said it is no longer available this usage?

@yunustek At the moment it looks like the way you can solve it by switching from Moya/Alamofire to native URLSession.

Okay thanks @polurezov8

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hamada147 picture hamada147  路  3Comments

sunshinejr picture sunshinejr  路  3Comments

ghost picture ghost  路  3Comments

dimpiax picture dimpiax  路  3Comments

pedrovereza picture pedrovereza  路  3Comments