alamofire

Proper usage of the Alamofire's URLRequestConvertible

耗尽温柔 提交于 2019-11-27 05:00:46
问题 I've read couple tutorials, README from @mattt but can't figure out couple things. What is the proper usage of URLRequestConvertible in real world API? It looks like if I will create one router by implementing URLRequestConvertible protocol for all API - it will be barely readable. Should I create one Router per endpoint? Second question most likely caused by lack of experience with Swift language. I can't figure out why enum is used for building router? Why we don't use class with static

Getting client certificate to work for mutual authentication using Swift 3 and Alamofire 4

别说谁变了你拦得住时间么 提交于 2019-11-27 04:40:47
I am trying to figure out how to use Alamofire 4.0 with Swift 3.0 to send a p12 (i also have the PEM cert and key if need be) to a website for authentication. All the examples i have seen are for Swift 2.0 and not exactly what i'm looking for. In safari on my mac i can access the site by putting the p12 in the keychain and sending it when safari asks so i know that portion works. I don't know if anyone can help me with an example of how to do so in Alamofire 4.0 and Swift 3.0 in an application. The certificates are self signed as well. Any thoughts or help? I am not just looking to pin the

Handle timeout with Alamofire

人走茶凉 提交于 2019-11-27 04:20:38
问题 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,

How to disable caching in Alamofire

痞子三分冷 提交于 2019-11-27 04:10:47
When I send a GET request twice with Alamofire I get the same response but I'm expecting a different one. I was wondering if it was because of the cache, and if so I'd like to know how to disable it. swift 3, alamofire 4 My solution was: creating extension for Alamofire: extension Alamofire.SessionManager{ @discardableResult open func requestWithoutCache( _ url: URLConvertible, method: HTTPMethod = .get, parameters: Parameters? = nil, encoding: ParameterEncoding = URLEncoding.default, headers: HTTPHeaders? = nil)// also you can add URLRequest.CachePolicy here as parameter -> DataRequest { do {

How to use NetworkReachabilityManager in Alamofire

被刻印的时光 ゝ 提交于 2019-11-27 04:02:55
问题 I want functionality similar to AFNetworking in Objective-C with Alamofire NetworkReachabilityManager in Swift: //Reachability detection [[AFNetworkReachabilityManager sharedManager] startMonitoring]; [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { switch (status) { case AFNetworkReachabilityStatusReachableViaWWAN: { [self LoadNoInternetView:NO]; break; } case AFNetworkReachabilityStatusReachableViaWiFi: { [self

Alamofire invalid value around character 0

谁说胖子不能爱 提交于 2019-11-27 03:47:59
Alamofire.request(.GET, "url").authenticate(user: "", password: "").responseJSON() { (request, response, json, error) in println(error) println(json) } This is my request with Alamofire, for a certain request it sometime works, but sometimes i get: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 0.) UserInfo=0x78e74b80 {NSDebugDescription=Invalid value around character 0.}) I've read that this can be due to invalid JSON, but the response is a static json string that i have validated in JSON validator

Module 'Alamofire' has no member named 'request'

北战南征 提交于 2019-11-27 03:43:20
问题 I'm new to iOS Development, I installed Alamofire as said in README, but I have this error as other users and I don't know how to solve it. 回答1: Alamofire.xcodeproj -> Build Phases -> Complie Sources If (0 item) , then " [+] Alamofire.swift ". It's OK :) 回答2: 2019 UPDATE If you have this error and you use 'alamofire5' branch just change Alamofire.request to AF.request . 回答3: if you are using new Alamofire 5.xxx then you will use AF instead of Almofire it like that AF.upload(multipartFormData:

Background request not execute Alamofire Swift

血红的双手。 提交于 2019-11-27 02:52:54
问题 I'm trying to make calls in background like POST,GET to be more precise in the didReceiveRemoteNotification method, because they start to work as a push notification arrive. My problem is that all the Alamofire.request are never call in Background mode until I open the app. I have by now Im was trying to open a session but it won't make the request work. These is what i want to execute in background (cellphone in background) Alamofire.Manager(configuration: configuration).request(.GET, url,

How to clear AlamofireImage setImageWithURL cache

陌路散爱 提交于 2019-11-27 02:17:00
问题 I am using AlamofireImage in my project quite a lot and I use let URL = NSURL(string: "https://cdn.domain.com/profile/image.jpg")! imageView.af_setImageWithURL(URL) to fetch an image from my CDN. I have done some tests but correct me if I am wrong, this seems to store the downloaded image in to a cache. My tests included downloading a 5mb image. The first time it took about 20 seconds, the second time was instant. The thing I would like to know is how can I clear the cache for a specific URL