alamofire

get data from AF responseJSON

荒凉一梦 提交于 2020-01-06 06:27:00
问题 I have code to process location data so I can extract details that can anonymize the data -- for example, if my places API says it is a _type: "Building" and building: "Safeway" -- I could save the data as an md5 of the lat/long:"safeway", and all safeways would look the same when inspecting my location data. That's also what I want. static func getLocationData(location: CLLocation, _ callback: @escaping (CLLocation?) -> Void) { let parameters = [ "q": location.coordinate.latitude.description

post form_data data with alamofire not work

半世苍凉 提交于 2020-01-06 05:29:07
问题 i want to send data and image from my apps but not send with this code let parameters: [String: AnyObject] = [ "latitude" : lat as AnyObject, "longitude" : lng as AnyObject, "lokasi" : txtAlamat.text as AnyObject, "keterangan" : txtKeterangan.text as AnyObject, "jenis_absen" : absenIndex as AnyObject ] let requestUrl = "https://link.co/link_me" Alamofire.request(requestUrl, method: .post, parameters: parameters, encoding: JSONEncoding.default).authenticate(user: username!, password: password!

Sending POST request to API using Alamofire

本小妞迷上赌 提交于 2020-01-06 05:25:14
问题 So Im using an API for an app that helps me store data for events where i send data to the API entered/selected by the user store it and get back an ID to reference to later. Here is some code that Im using. JSON accepted by API { "topic":"test shedule", "setdate":"21-09-2017", "scheduledate":"22-09-2017", "settime":"09:00:00", "scheduletime":"10:00:00", "agenda":"hi this is test agenda", "adminname":"name", "type":"meeting", "users": "[{\"category\":\"optional\",\"email\":\"abc@gmail.com\"}]

Alamofire request to twilio swift

↘锁芯ラ 提交于 2020-01-06 05:22:25
问题 I'm trying to get an SMS from twilio.com but get nil in response. Can anyone say what I'm doing wrong? class SMSVerificationService: NSObject { static let sharedInstance = SMSVerificationService() func SMSRequest(countryCode:String, phoneNumber: String) { let accountSid = "ACc4d9785419f144412823ff20as34660c3d" let authToken = "4wqecx41f8999caa23735da214" // changed :) let url = URL(string: "https://\(accountSid):\(authToken)@api.twilio.com/2010-04-01/Accounts\(accountSid)/Messages") print(

libc++abi.dylib: terminating with uncaught exception of type NSException Alamofire

核能气质少年 提交于 2020-01-06 02:45:27
问题 I am sending images to the server using alamofire. If parameters ; let parameters: Parameters = [ "userID": "1", "acToken": "acToken" ] working but parameters ; let parameters: Parameters = [ "userID": userID, "acToken": acToken ?? "" ] not working. error = libc++abi.dylib: terminating with uncaught exception of type NSException I'm using swift4, alamofire 4, Xcode 9.2 My upload method : func profilePhotoUpload(){ let defaults = UserDefaults.standard let userID = defaults.integer(forKey:

Synchronous request using Alamofire

跟風遠走 提交于 2020-01-05 21:15:21
问题 I have checked other solutions like How to make a synchronous request using Alamofire?, I followed all instructions but I haven't been able to complete the requests and then use the information. I need to retrieve distance and route points from google maps and then complete an array with that information. This is the function: func getGoogleMapsInfo(startLocation: CLLocationCoordinate2D, restaurant: Customer, completion: @escaping (_ distance: Int, _ routePoints: String) -> ()){ let

Alamofire HTTP requests fails

六月ゝ 毕业季﹏ 提交于 2020-01-05 21:09:12
问题 I made some HTTP requests using Alamofire. Some request has been succeeded and some are failed. error is Invalid value around character 0. Failed request gave me above error. bellow i have mentioned a sample code which failed. let parameters = ["amount": ["10"], "payment_method": ["paypal"], "date": ["2015-11-25"], "details": ["Payment description"]] let headers = [ "Accept": "*/*", "Content-Type": "application/json" ] let url = "https://livetest.somedomain.com/api/invs/LAT1j5da99PdPg

Serializing JSON object with Alamofire

落爺英雄遲暮 提交于 2020-01-05 05:41:08
问题 Im trying to run to serialize the JSON response, but I am getting an error on the "let json = ..." line. The error is "Ambiguous reference to member 'jsonObject(with:options:)'". If anyone knows how to fix this I will apprechiate it Alamofire.request("https://httpbin.org/get").responseJSON { response in if let JSON = response.result.value { do { let json = try JSONSerialization.jsonObject(with: response.result.value!, options: .allowFragments) } catch { print () } print("JSON: \(JSON)") } }

Ambiguous reference to member subscript in Alamofire

こ雲淡風輕ζ 提交于 2020-01-05 04:40:07
问题 Alamofire.request(videosUrl!).responseJSON { response in if response.result.value != nil { let json = response.data do { let readableJSON = try JSONSerialization.jsonObject(with: json!, options: .mutableContainers) as? JSONStandard if let items = readableJSON { for i in 0..<items.count { let item = items[i] <<< ERROR HERE ...REST OF CODE HERE } } } catch { print(error) } } } I also have a typealias set: typealias JSONStandard = [String:AnyObject] My question is why am I getting the 'Ambiguous

OSStatus error 1685348671 AVAudioPlayer

拟墨画扇 提交于 2020-01-05 04:23:06
问题 I'm trying to download mp3 file with Alamofire and save it to desired location. Then, from that location, I'm trying to play that file, but it gives me an error. This is download function func downloadSong(song: Song, completion: @escaping(Bool) -> ()) { var headers: HTTPHeaders = [:] if let authorizationHeader = Request.authorizationHeader(user: Constants.authName, password: Constants.authKey) { headers[authorizationHeader.key] = authorizationHeader.value } let destination: DownloadRequest