呼叫

时间:2017-07-01 06:16:05

标签: ios swift3 alamofire

过去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)

1 个答案:

答案 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)

            }
        })