Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to get logs of api called using URLSession. #160

Open
NayanBhut opened this issue May 24, 2023 · 2 comments
Open

Not able to get logs of api called using URLSession. #160

NayanBhut opened this issue May 24, 2023 · 2 comments

Comments

@NayanBhut
Copy link

NayanBhut commented May 24, 2023

This code is in ViewController.swift file in demo. I am not able to get this api log because it is called using URLSession. Please check.

`

func testRedirect() {

    let request = URLRequest(url: URL(string: "https://www.google.com")!, cachePolicy: .reloadIgnoringLocalCacheData)
    let task = URLSession.shared.dataTask(with: request) { data, response, error in
        if let error = error {
            completionHandler(false, error.localizedDescription)
            return
        }

        if let httpResponse = response as? HTTPURLResponse {
            if (300...302).contains(httpResponse.statusCode) {
                completionHandler(true, httpResponse.allHeaderFields["Location"] as! String)
                return
            }
        }

        completionHandler(false, "Redirect request failed")
    }
    task.resume()
}

`

@ParasGarg7
Copy link

Have tried this on these devices as well - iPhone 13 - 16.4(physical Device), iPhone 14 (iOS 17).
Seems to be OS and Device independent.
Did you find any solution?

@harjeetk
Copy link

harjeetk commented Apr 5, 2024

This is still happening, Have we found any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants