App Transport Security阻止了明文HTTP(http://)资源加载,因为它不安全?

时间:2015-11-05 03:44:42

标签: http

我坚持这个错误我该怎么办? Transport security has blocked a cleartext HTTP但这不起作用我能做什么 让Url = NSURL(字符串:“http://mydomain.com.mx/ObtenerMapa.php”)

    let rqst = NSMutableURLRequest(URL: Url!)

    rqst.HTTPMethod = "POST"

    //rqst.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)

    let tarea = NSURLSession.sharedSession().dataTaskWithRequest(rqst)
        {
            (data,response,error )in
            if error != nil
            {
                return

            }

            //var err: NSError?
            do {
                let json = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? NSDictionary
                //let responseString = NSString (data: data, encoding: NSUTF8StringEncoding)
                if let parseJson = json {
                    let mensaje = "Mensaje"
                    let error = "Error"
                    print(parseJson)
                    //let mensaje =  (parseJson["mensaje"] as? String)!
                    //let error =  (parseJson["status"] as? String)!
                    completion(message: mensaje, error: error)

                }else{
                    completion(message: "Servicio no disponible", error: "Error")
                }
            } catch {
                completion(message: "Servicio no disponible", error: "Error")
            }

    }


    tarea.resume()

0 个答案:

没有答案