alamofire

unwrapping an Optional value

不问归期 提交于 2019-12-08 04:53:21
问题 I am trying to login with macbook using code but I keep on getting this error: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value // API to log an user in func login(userType: String, completionHandler: @escaping (NSError?) -> Void) { let path = "api/social/convert-token/" let url = baseURL!.appendingPathComponent(path) let params: [String: Any] = [ "grant_type": "convert_token", "client_id": CLIENT_ID, "client_secret": CLIENT_SECRET, "backend": "facebook",

It shows 405 Server error at first time to get result from API server, and it works fine at second time

孤街浪徒 提交于 2019-12-08 04:32:36
问题 It shows 405 Server error at first time to get result from API server, and it works fine at second time. I've been trying to solve this issue for a month and couldn't find the solution. I used Xcode 9.2, Swift 4, and Alamofire 4.6. Main problem - API server logs suppose to show "POST" on http method. Howerver it shows only "ST" on http method. (This is the main problem.) This caused to get 405 server error. My Source Codes using Alamofire Alamofire.request(url, method: .post , parameters: [

Using a value from Alamofire request outside the function

风流意气都作罢 提交于 2019-12-08 02:47:45
问题 I can't seem to figure this one out: I am trying to get an error from my server (in JSON) using an Alamofire request, but I cannot get the value outside the function. This is the implementation of my function: func alamoRequest(username : String, email: String, password: String, facebook: String, completionHandler : (String?) -> Void) { var jsonValue : JSON? let URL = "http://someurl.com/login.php" let requestParameters = ["username" : username, "email" : email, "password" : password,

Alamofire Background Service, Global Manager? Global Authorisation Header?

左心房为你撑大大i 提交于 2019-12-08 00:08:21
问题 Can anyone tell me how to use the Alamofire background service correctly? My attempts are: Login View Controller // Create a global variable for the manager var manager = Alamofire.Manager() var configuration = NSURLSessionConfiguration() class LoginViewController: UIViewController { // set the configuration for the manager configuration = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier("com.xxx.app.backgroundService") configuration.sharedContainerIdentifier = "com.xxx

Entering username and password for Alamofire request

爷,独闯天下 提交于 2019-12-07 17:50:26
问题 I'm trying to use Alamofire to do a GET request for my iOS app, but I don't really know how to enter my username and password. The cURL command that ran successfully was curl -k -u user:pw https://url/ cli /method and it returned the correct JSON for Alamofire I tried Alamofire.request(.GET, self.baseURL + method, parameters: params).responseJSON { (_, _, JSON, _) in println(JSON) where baseURL + method is https://url/ rest /method and params is let params = [ "username" : self.username.text,

Importing Alamofire 3.4 - No such module 'Alamofire'

一世执手 提交于 2019-12-07 13:17:06
问题 I hava a project that need Alamofire imported and every aproach i took got me to same porblem import Alamofire - No such module 'Alamofire' Installed cocoapods Edited Podfile: source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.0' use_frameworks! target 'my project name' do pod 'Alamofire', '~> 3.4' end $ pod install everything was smooth and had no errors in the proces from installing cocoapods to the end. Opened project with projectname.xcworkspace Even tried the manually and

Swift Alamofire + Promise catching

馋奶兔 提交于 2019-12-07 12:27:16
问题 Folks, The following works except for the catch, xcode errors out with expected member name following '.' Is this the proper way to promisify with PromiseKit? All suggestions welcome! Thanks! @IBAction func loginButtonTapped(sender: AnyObject) { let email = userEmail.text! let password = userPassword.text! func onSuccess(success:Bool, message:String, token: String) -> Promise<Void> { if success { NSUserDefaults.standardUserDefaults().setBool(true, forKey: "isUserLoggedIn") NSUserDefaults

ResponseSerializer 'cannot call value of non-function type 'NSHTTPURLResponse?'' with Swift 3

◇◆丶佛笑我妖孽 提交于 2019-12-07 10:40:56
问题 I had been using the following code without issue until updating to Xcode 8 beta 6. It is similar to this example from the Alamofire repository. This morning I updated my Alamofire library to the latest swift3 branch, which is now compatible with beta 6. It shows the error: Cannot call value of non-function type 'HTTPURLResponse?' A similar question exists here, but it is not based on the current version of Swift and Alamofire. From what I understand, this error is because it thinks that I am

Alamofire 图片带参数 上传

泄露秘密 提交于 2019-12-07 10:08:07
Swift Alamofire 带参数 头像上传 , // 头像修改 func headerUpdateRequest(){ let parameters: NSMutableDictionary = NSMutableDictionary () parameters. setValue ( token , forKey: "token" ) parameters. setValue ( telephone , forKey: "telephone" ) showWatting () let url = URL (string: PATH_INFOUPDATE ) Alamofire. upload (multipartFormData: { (multipartFormData) in let _data = UIImageJPEGRepresentation (( self . headerImage ?. image )!, 0.5 ) let dateFormatter: DateFormatter = DateFormatter (); dateFormatter. dateFormat = "yyyyMMddHHmmss" let str = dateFormatter. string (from: NSDate () as Date )

Alamofire上传图片解决绑定参数问题

℡╲_俬逩灬. 提交于 2019-12-07 10:07:56
Alamofire上传图片解决绑定参数问题 今天记录下载使用Alamofire上传图片时遇到的一个问题,在很多APP里面都有这样的需求,就是上传用户的头像,头像当然是和用户的ID是一一对应的关系,所有在上传图片的时候需要向服务器上传用户的ID或者其他的参数。但是在Alamofire上传文件的API中并没有参数的设置,下面就来解决这个问题。 首先利用cocoaPods导入框架: use_frameworks! target 'YourTargetsName' do pod 'Alamofire' end Alamofire.upload(.POST, url, multipartFormData: { (multipartFormData) in for image in imageArrays { let data = UIImageJPEGRepresentation(image as! UIImage, 0.5) let imageName = String(NSDate()) + ".png" multipartFormData.appendBodyPart(data: data!, name: "name", fileName: imageName, mimeType: "image/png") } // 这里就是绑定参数的地方 param 是需要上传的参数