alamofire

Alamofire error after Swift 3.0 migration: “Extra argument in Call'” (request method)

↘锁芯ラ 提交于 2019-12-24 00:42:26
问题 I am currently in the process of updating my codebase to Swift 3.0, and I am using Alamofire. Thus, I had to update Alamofire to 4.0 (Alamofire git repo). I have a request method to fetch data from the server, and before migration, it worked wonderfully. After using Xcode's migration tool, I ended up with this error : "Extra argument in Call" . I'm not quite sure why this method is no longer working. Any help would be wonderful! class func makeRequest( _ method: RequestMethod, authorization:

iOS/Swift : How to manage network versatility with Alamofire

百般思念 提交于 2019-12-23 21:05:50
问题 I'm new in iOS and Swift development, and i'm not used to manage the network reachability in my usual programs. I found AFNetworking and Alamofire which are great frameworks to ease the API calls in iOS. But i have difficulties to figure out how to make some requests to wait until network is back if i'm loosing it. Typically during session login or getting some json lists or downloading images. Do you have some tutorials or examples i can rely on to improve my knowledge and be able to build a

Swift Alamofire Getting Token from Refresh Token Request Error

让人想犯罪 __ 提交于 2019-12-23 20:26:48
问题 I'm pretty new to using Alamofire, and I am banging my head against the wall with this request. I'm using GIDSignIn, and successfully get a token and refresh token for the user, with the scope ["https://www.googleapis.com/auth/youtube.readonly"]. I'm trying to complete this request, as shown as an example on the site. The site says to ignore using client_secret for iOS, which I do. POST /oauth2/v4/token HTTP/1.1 Host: www.googleapis.com Content-Type: application/x-www-form-urlencoded client

Alamofire: handle error with success response

别等时光非礼了梦想. 提交于 2019-12-23 15:19:36
问题 Hi i am still new to Alamofire and json. i just want to ask on how to handle error on success response. Below is the response of the api with post request. { data = { "cabinet_id" = 3289146811; "created_at" = "2018-04-11T04:53:43.288023001Z"; "user_id" = 123abc; }; } but sometimes i got response as below due to server error { error = { "http_status_code" = 400; message = "Unable to proceed"; type = "rent_request_failed"; }; } here is what i have did let url = "myurl" let parameters = ["user

How to write Unit Test for Alamofire request function?

…衆ロ難τιáo~ 提交于 2019-12-23 15:19:29
问题 I have a project where I'm sending .GET requests to get data from the server and for this I'm using Alamofire & SwiftyJSON. For example: I have file "Links", "Requests" and my ViewController. Links.swift var getAllData: String { return "\(host)api/getalldata" } Requests.swift func getAllData(_ completion:@escaping (_ json: JSON?) -> Void) { Alamofire.request(Links.sharedInstance.getAllData).validate().responseJSON { (response) in do { let json = JSON(data: response.data!) completion(json) } }

SSL Pinning with fingerprint in Alamofire

痞子三分冷 提交于 2019-12-23 13:32:55
问题 Has anyone seen a way to do pinning with Alamofire with the fingerprint instead of the public key? Sorry if this has been answered, I haven't seen it anywhere. Thanks 回答1: This ended up being pretty straight forward. The code below might not be perfect, my real code is doing some addtional checks, but this is most of it. The .SHA1Fingerprint is an extension method on SecCertificate that copies it into NSData and then converts it to a SHA1. I use RNCryptor to do that, but you can do it however

Sending json object in GET request in swift in Alamofire

▼魔方 西西 提交于 2019-12-23 13:12:33
问题 I'm trying to execute a GET requst with json object binded to it , This i how i generated JSON object let jsonObject: [String: AnyObject] = [ "ean_code": [ "type": "match", "value": "16743799" ] ] and then I executed the request like this Alamofire.request(.GET,Constant.WebClient.WS_URL + "/product?filters="+String(jsonObject),parameters:parameters) but this gave me an error which is canot bind the URL with invalid character so i encoded the URL from this let request = String(jsonObject)

why is string response from server changing when I am using alamofire in ios app?

≯℡__Kan透↙ 提交于 2019-12-23 06:58:25
问题 I am trying to retrieve a string from server using alamofire in an ios app but the problem is that the response is changing as it is prefixing ever entity with "\" character. here is my code: func getInformation() { self.activityIndicator.startAnimating() let parameters: Parameters = ["SchoolCode": "TCenYrhWUQH7kKLVZ1FQgQ==", "FacultyInfoCode":"cFl9ivLKKKk5PgH4tbi/Gg=="] Alamofire.request("http://epunjabschool.gov.in/webservice/staffwebservice.asmx/StaffDetails", method: .post, parameters:

Subclassing URLProtectionSpace

ε祈祈猫儿з 提交于 2019-12-23 04:57:24
问题 Aim: Test SSL pinning by using URLProtocol. Problem: Cannot subclass URLProtectionSpace in the expected manner. The server trust property is never called and the alamofire auth callback only receives a URLProtectionSpace class type instead of my class even though the initializer of my custom class gets called. Configuration: [using Alamofire] let sessionConfiguration: URLSessionConfiguration = .default sessionConfiguration.protocolClasses?.insert(BaseURLProtocol.self, at: 0) let

How to upload zip file to server with MultipartFormData in iOS Swift?

妖精的绣舞 提交于 2019-12-23 04:41:49
问题 I am trying to upload a zipfile to the server. When i tried to upload a zip file to the server, File is not getting uploaded successfully. I am getting error from the server. At the server side userid is separated from the file name. The actual server JSON response is: {"error":{"login":"Sorry,Failed to Login "}} I am new to multipart/form-data , so I don't know the cause behind this issue. This is my code: func uploadData() { let headers: HTTPHeaders = [ "Content-type": "multipart/form-data"