过去2天面对此问题。我更新了pod,将更新的pod版本从 4.0.1 更新为 4.5.0 ,但问题仍然存在。
这是我的代码:
var params: Parameters = [:]
params = [
"id": fetchFromCoreData(keyVlue: "trsptrRegistrationId") as AnyObject,
"mobileNumber": fetchFromCoreData(keyVlue: "mobileNO") as AnyObject,
"isNotification": isnotifyTag as AnyObject
]
print(params)
let auth_token = fetchFromCoreData(keyVlue: "Auth_Token")
let headers = [
"authKey": auth_token
]
print(headers)
let URL: String = GlobalUrls.BASE_URL + GlobalUrls.notifySetting
print(URL)
Alamofire.request(URL, method: .post, parameters: params, encoding: JSONEncoding.default, headers: headers)
答案 0 :(得分:0)
var param :Parameters
param = [
"id": "Any id",
"mobileNumber": "any mobile number",
"isNotification": "is notification"
]
print(param)
let auth_token = "your auth_token"
let headers = [
"authKey": auth_token
]
print(headers)
let base_url: String = "Here is my base URL"
print(base_url)
Alamofire.request(base_url, method: .post, parameters: param, encoding: JSONEncoding.default, headers: headers).responseJSON(completionHandler: {(resObj) -> Void in
print(resObj)
if resObj.result.isSuccess
{
print("Sucess result")
}
if resObj.result.isFailure
{
let error : Error = resObj.result.error!
print("Fail result")
print(error.localizedDescription)
}
})