Questions tagged [alamofire]

Alamofire is an HTTP networking library written in Swift.

Alamofire is an HTTP networking library written in Swift.

Features

  • Chainable Request / Response Methods
  • URL / JSON / plist Parameter Encoding
  • Upload File / Data / Stream / MultipartFormData
  • Download File using Request or Resume Data
  • Authentication with URLCredential
  • HTTP Response Validation
  • Upload and Download Progress Closures with Progress
  • cURL Command Output
  • Dynamically Adapt and Retry Requests
  • TLS Certificate and Public Key Pinning
  • Network Reachability
  • Comprehensive Unit and Integration Test Coverage

Project

6065 questions
21
votes
2 answers

How to pause/resume/cancel my download request in Alamofire

I am downloading a file using Alamofire download with progress but i have no idea how to pause / resume / cancel the specific request. @IBAction func downloadBtnTapped() { Alamofire.download(.GET, "http://httpbin.org/stream/100", destination:…
Zeeshan
  • 211
  • 1
  • 2
  • 3
20
votes
1 answer

How to use Alamofire 4 SessionManager?

I was using Alamofire 3.4 in Swift 2.3 and I need to update my code to Swift 3 and Alamofire 4. I was using Alamofire's Manager to do a POST in a url. I read the documentation about SessionManager and I understand that the request uses the method…
yasin
  • 1,297
  • 3
  • 17
  • 36
20
votes
1 answer

Alamofire download issue

I am trying to download this picture in my code using Alamofire 4.0.0 with Xcode 8.0 and Swift 3.0. Here is my request: func download(_ path: String, _ completionHandler: @escaping (Any?) -> ()) { let stringURL =…
Tulleb
  • 8,919
  • 8
  • 27
  • 55
20
votes
4 answers

Generate cURL output from Alamofire request?

The documentation for Alamofire says that it produces cURL debug output. But for the life of me, I can't figure out how to retrieve the cURL for my request. Can someone enlighten me on the proper syntax for showing the cURL request as in my debug…
Greg Ferreri
  • 2,652
  • 5
  • 28
  • 38
20
votes
5 answers

How to read response cookies using Alamofire

I am trying to read the response cookies for a post request, as done by Postman below The way I am trying without success right now is var cfg = NSURLSessionConfiguration.defaultSessionConfiguration() var cookies =…
abinop
  • 3,153
  • 5
  • 32
  • 46
20
votes
5 answers

How to connect to self signed servers using Alamofire 1.3

I get the below error while connecting to self signed server. Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “maskeddomain.com” which could put your…
Arasan Rajendren
  • 265
  • 1
  • 2
  • 7
19
votes
2 answers

Update responseJSON to responseDecodable in Swift

I'm new to Swift and I'm trying to upgrade some old Swift code. I'm getting the below warning: 'responseJSON(queue:dataPreprocessor:emptyResponseCodes:emptyRequestMethods:options:completionHandler:)' is deprecated: responseJSON deprecated and will…
thecoolmacdude
  • 2,036
  • 1
  • 23
  • 38
19
votes
1 answer

How to convert "2017-01-09T11:00:00.000Z" into Date in Swift 3?

My problem is that the date is nil. My code looks like print(article_date) // output "2017-01-09T11:00:00.000Z" as string let dateFormatter = DateFormatter() dateFormatter.locale = Locale(identifier: "en_US_POSIX") dateFormatter.dateFormat =…
Lyndon King McKay
  • 647
  • 2
  • 7
  • 10
19
votes
1 answer

Alamofire memory leaks Instruments

I am trying to clean my app from memory leaks and I have a few problems understanding this Why Alamofire function Request.serializeResponseJSON is called 30 seconds after I've launched app: I did not touch anything or navigate anywhere, the screen…
JuicyFruit
  • 2,638
  • 2
  • 18
  • 35
19
votes
7 answers

Handle No Internet Connection Error Before Try to Parse the Result in Alamofire

How should I handle if there is an error occurs when there is no internet connection in Alamofire. I tried checking if data is nil or not but it does not work. Below is how I use Alamofire Alamofire.request(.POST, REGISTER_URL, parameters:…
JayVDiyk
  • 4,277
  • 22
  • 70
  • 135
19
votes
2 answers

Best way to Cache JSON from API in SWIFT?

I need to cache json data from API in swift. So I researched a Lot & get to this Post. I tried to implement the Option 1 in my App. But the Custom manager always returned nil. I don't know why? After that I got AwesomeCache. It says that it an do…
AruLNadhaN
  • 2,808
  • 5
  • 24
  • 42
19
votes
3 answers

ssl pinning in Swift AlamoFire

Im a newb here but I have an app that is subject to MITM attacks. After I bit of research it sounds like I need to do SSL Pining, i.e keep a copy of my servers public key/certificate so the can determine if the response came from it. I have no idea…
user3412996
  • 191
  • 1
  • 1
  • 4
19
votes
1 answer

AlamoFire GET api request not working as expected

I am trying to get learn how to use AlamoFire and I am having trouble. My method so far is as follows: func siteInfo()->String?{ var info:NSDictionary! var str:String! Alamofire.request(.GET, MY_API_END_POINT).responseJSON {(request,…
boidkan
  • 4,691
  • 5
  • 29
  • 43
18
votes
1 answer

How to use Alamofires ServerTrustPolicy.disableEvaluation in swift 5 alamofire 5.0.3

in alamofire 4 I used this code to disable sever evaluation: private var Manager : Alamofire.Session = { // Create the server trust policies let serverTrustPolicies: [String: ServerTrustPolicy] = ["serverurl.com":…
Yoel Jimenez del valle
  • 1,270
  • 1
  • 9
  • 20
18
votes
1 answer

Best practices for storing a Token in iOS app

I'm creating an iOS that interacts with an API using Alamofire, and requires a Token for most requests. I've built the app using the MVC pattern, and it works great, but I've encountered a problem as I've tried to integrate the API. How should I…
Matthew Harries
  • 630
  • 1
  • 6
  • 9