Is there a way to do Alamofire requests with retries

后端 未结 4 2000
离开以前
离开以前 2020-12-15 09:09

I have a lot of places in the code where Alamofire request/response are handled.

Each of this requests may fail because of some intermittent problem (the most commo

4条回答
  •  爱一瞬间的悲伤
    2020-12-15 09:29

    I've created one wrapper class for request retrier should function. https://gist.github.com/daljeetseera/7ce2b53b8a88d8a5e9b172c0495c6455

    And used the request retrier in session manager required for request.

    static let sharedManager: SessionManager = {
            let configuration = URLSessionConfiguration.default
            let manager = Alamofire.SessionManager(configuration: configuration)
            let requestRet = NetworkRequestRetrier()
            manager.retrier = requestRet
            return manager
        }()
    
    

提交回复
热议问题