Swift 3 - Alamofire request - Save request to disk

和自甴很熟 提交于 2019-12-11 08:08:28

问题


I am asking this question because I didn't found any resources on this issue, and therefore I can't complete my project on this.

I have this basic alamofire post request:

let request = Alamofire.request("https://httpbin.org/post", method: .post, parameters: parameters, encoding: JSONEncoding.default)

If I am not connected to the Internet, I want to save this request and then perform it again when the internet is connected.

Any ideas on how to start on this issue? Any suggestion will be very much appreciated.


回答1:


  1. With the help of this answer determine if there is working internet connection or not.

  2. case when there is no internet connection
    Save your post parameters in your user default or file

  3. Follow this answer to get to know when iphone is again connected to internet.

  4. with the help of answer linked in step 2 read your parameters from file and make the post request



来源:https://stackoverflow.com/questions/46267512/swift-3-alamofire-request-save-request-to-disk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!