Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1522

iOS swift: App Transport Security has blocked a cleartext HTTP (http://) resource

$
0
0

Evening, I'm working on an app based on the SWAPI (Star Wars API: https://swapi.co/documentation)

And I got the ATS Error:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

I can't understand the reason. My baseURL is on https format

struct NetworkManager {    let baseURL = "https://swapi.co/api/"    let session = URLSession(configuration: .default)    func fetchEndpoint(endpoint: Endpoint, completion: @escaping (_ response: Result) -> Void) {        self.fetchURL(url: baseURL + endpoint.URL(), completion: completion)    }    func fetchURL(url: String, completion: @escaping (_ response: Result) -> Void) {        let url = URL(string: url)!        let request = URLRequest(url: url)        let task = session.dataTask(with: request) { data, response, error in            if error != nil {                completion(.Failure(error))            } else {                if let data = data {                    if let json = try? JSONSerialization.jsonObject(with: data, options: []) {                        OperationQueue.main.addOperation({                            switch json {                            case let objectResponse as JSONArray: completion(.Success(objectResponse as AnyObject?))                            case let objectResponse as JSONDict: completion(.Success(objectResponse as AnyObject?))                            default: break                            }                        })                    }                }            }        }        task.resume()    }}

Please give me and hint!I'm just new, and I'm guessing that the SWAPI supports only the http protocol.


Viewing all articles
Browse latest Browse all 1522

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>