When I try to load url from iOS webview, the page does not load with the message App Transport Security has blocked...

Asked 2 years ago, Updated 2 years ago, 63 views

let url = NSURL (string: "http://google.com");
let requestObj = NSURLRequest(URL: url!);
myWebView.loadRequest(requestObj);

Loading url with

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.

The page doesn't load in the webview.

What should I do?

ios swift webview

2022-09-22 21:51

1 Answers

It's a self-answer.

If you enter Target Settings, there is a menu called Custom iOS Target Properties. From there, mouse over the area shown in the image below to create a + button.

After pressing the button, you can add a menu called App Transport Security Setting as shown below.

Then change Allow Arbitrary Loads to Yes.


2022-09-22 21:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.