美文网首页
学会用Alamofire

学会用Alamofire

作者: 青春已给下一代 | 来源:发表于2020-02-20 19:59 被阅读0次

         let key = ""

            let secret = ""

            let data = ["platform":"all","audience" : ["alias" : ["162625"]],"message" : ["msg_content" : "Hi,JPush","content_type" : "text","title" : "msg","extras" : ["key": "value"]]] as [String : Any]

            let path = "https://api.jpush.cn/v3/push"

            varheaders:HTTPHeaders= [:]

            ifletauthorizationHeader =Request.authorizationHeader(user: key, password: secret) {

                headers[authorizationHeader.key] = authorizationHeader.value

            }

            Alamofire.request(path, method: .post, parameters: data, encoding:JSONStringArrayEncoding(array: data), headers: headers)

                .authenticate(user: key, password: secret)

                .validate(contentType: ["application/json"])

                .responseJSON{ responsein

                    ifletJSON = response.result.value{

                        print("JSO: \(JSON)")

                    }

            }

    相关文章

      网友评论

          本文标题:学会用Alamofire

          本文链接:https://www.haomeiwen.com/subject/dvrfqhtx.html