ema so
ema so

Reputation: 129

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.

Upvotes: 4

Views: 5018

Answers (3)

Abhishek Mitra
Abhishek Mitra

Reputation: 3395

You have to add

<key>NSAppTransportSecurity</key>
 <dict>
      <key>NSAllowsArbitraryLoads</key>
     <true/>
 </dict>

in your info.plist because your link "http://fatima.ibtdi.work" is not secured by SSL, so you have to add NSAppTransportSecurity in your info.plist file. IOS manage the link if the link is secured with SSL certificates else it block transportation from device to web.

Hope this helps you.

Upvotes: 2

KKRocks
KKRocks

Reputation: 8322

Add this to your plist

<key>NSAppTransportSecurity</key>
 <dict>
      <key>NSAllowsArbitraryLoads</key>
     <true/>
 </dict>

Upvotes: 4

zfetters
zfetters

Reputation: 457

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.

Upvotes: 3

Related Questions