alamofire

Handle timeout with Alamofire

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is it possible to add timeout handler for Alamofire request? In my project I use Alamofire this way: init() { let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() configuration.timeoutIntervalForRequest = 30 self.alamofireManager = Alamofire.Manager(configuration: configuration) } func requestAuthorizationWithEmail(email:NSString, password:NSString, completion: (result: RequestResult) -> Void) { self.alamofireManager!.request(.POST, "myURL", parameters:["email": email, "password":password]) .responseJSON { response in

iOS 9.3 : An SSL error has occurred and a secure connection to the server cannot be made

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting following error with self signed certificate Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made. while testing web-services for one of my demo app with iOS 9.3 XCode 7.3 Swift 2.2 Alamofire 3.3.0 and Local server : https://filename.hostname.net Note: before assuming its Duplicate, I would request please read it all the way,even same i have reported to apple dev forums Using Alamofire Library func testAlamofireGETRequest() -> Void { Alamofire.request(.GET,

Swift Alamofire Getting Token from Refresh Token Request Error

匿名 (未验证) 提交于 2019-12-03 01:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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_id=<your_client_id>& client_secret=<your_client

Alamofire 关于Response的思考

匿名 (未验证) 提交于 2019-12-02 23:55:01
Alamofire 关于Response的思考。 你好,我是Emma,今天我们开启对Alamofire 关于Response的思考。主要的思考方向以下方示例为切入点。 示例: SessionManager.default.request(urlString) //默认的请求 .response(completionHandler: { (dataResponse) in dataResponse.response }) //自定义序列化的请求 .response(responseSerializer: DataResponseSerializer<String>.init(serializeResponse: { (request, response, data, error) -> Result<String> in print("原始数据:\(response)") return .success("成功啦") })) { (dataResponse) in print(dataResponse) } //系统封装过的序列化请求 .responseJSON { (jsonResponse) in print(jsonResponse) } ###1.Alamofiren中Response这个角色的作用是什么? 首先在查看源码之前,通过上面的代码我们思考一下

Alamofire download issue

荒凉一梦 提交于 2019-12-02 22:30:10
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 = "https://slove.tulleb.com/uploads/6/6/0/2/66027561/2791411.jpg-1447979839.png" print("Requesting \(stringURL)...") _ = Alamofire.download(stringURL) .responseData { response in print(response) if let data = response.result.value { completionHandler(UIImage(data: data)) } else { completionHandler(nil) } } } I get the following answer from the server: FAILURE:

Alamofire4 migration, Apple Mach-O Linker (id) Error

时光总嘲笑我的痴心妄想 提交于 2019-12-02 22:11:50
问题 After spending weeks migrating all my Alamofire code to AF4/Swift3, I finally fixed all the complier errors due to Alamofire Function changes, but now when I try to build a I get a whole bunch of these Apple Mach-O errors. There's at least 29 of them and they all have either Alamofire or AlamofireImage in them (aside from the last one which is "Linker command failed with exit code 1"). I don't have a clue of what to do here, I'll post any extra info needed, can anyone help me out here? edit:

Alamofire returns .Success on error HTTP status codes

痞子三分冷 提交于 2019-12-02 22:07:24
I have a pretty simple scenario that I'm struggling with. I'm using Alamofire to register a user on a rest API. The first call to register is successful and the user can log in. The second call, when trying to register with the same email address should result in a HTTP status code 409 from the server. Alamofire, however, returns a .Success with an empty request and response. I have tested this this API with postman and it correctly returns a 409. Why is Alamofire not returning .Failure(error), where the error has status code info etc? Here is the call I run with the same input each time.

How to run synchronically two functions with async operations on iOS using Swift

让人想犯罪 __ 提交于 2019-12-02 20:56:34
lets propose this scenario a method with async network operations func asyncMethodA() -> String? { result : String? Alamofire.manager.request(.POST, "https://www.apiweb.com/apimethod", parameters: parameters, encoding:.JSON) .response { (request, response, rawdata, error) in if (response?.statusCode == 200) { //DO SOME HEAVY LIFTING } } return result //string } another method with async network operations func asyncMethodB() -> String? { result : String? Alamofire.manager.request(.POST, "https://www.yetanotherapiweb.com/apimethod", parameters: parameters, encoding:.JSON) .response { (request,

Inserting data into realm DB with progress?

 ̄綄美尐妖づ 提交于 2019-12-02 20:04:27
问题 I have request data which was about 7MB after it has downloaded the json string,means the json string is about 7MB.After it has downloaded,I would like to save the data into realm model object(table) with progress like (1/7390) to (7390/7390) -> (data which is inserted/total data to be inserted) I am using Alamofire as HTTPClient at my app.So,how to insert data with progress into my realm object model after it has downloaded from server?Any help cause I am a beginner. I wont show the data

progress view in alamo fire will not update when downloading file in swift 3

十年热恋 提交于 2019-12-02 19:17:54
问题 I want to download a file with alamo fire and using alert with progress to show it but the progress will not move when alamo fire progress.fractionCompleted increased I use static var to equal progres.fractionCompleted but it doesn't worked too here is my codes let destination = DownloadRequest.suggestedDownloadDestination() Alamofire.download("example.com", to: destination).downloadProgress(queue: DispatchQueue.global(qos: .utility)) { (progress) in print("Progress: \(progress