Swift 3 - Alamofire request - Save request to disk

2019-07-25 19:12发布

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条回答
Summer. ? 凉城
2楼-- · 2019-07-25 19:47
  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

查看更多
登录 后发表回答