Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't load my web view with an http URL

I have a problem in loading in my web view This is my code:

NSString *urlString = @"https://www.google.com.eg";

//    NSString *urlString = @"http://fatima.ibtdi.work";

NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[_fatimaView loadRequest:urlRequest];}

It works on Google but doesn't work on the another link.

like image 248
ema so Avatar asked Sep 05 '25 22:09

ema so


2 Answers

Add this to your plist

<key>NSAppTransportSecurity</key>
 <dict>
      <key>NSAllowsArbitraryLoads</key>
     <true/>
 </dict>
like image 174
KKRocks Avatar answered Sep 10 '25 01:09

KKRocks


Looks like you need to add some App Transport Security Settings to your Info plist try this enter image description here

Any HTTP loading in a web view will require adding the domain to these settings.

like image 26
zfetters Avatar answered Sep 10 '25 00:09

zfetters