I am creating an application for ios by using Swift
. My Xcode version 7.0.1.
Basically i want to display some web pages in UIWebView
and social media integration (Facebook) and displaying one FaceBook page. I use the following items in Info.plist
file.
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
</dict>
</dict>
</dict>
Now FaceBook share (integration) working. Displaying web pages working but displaying Facebook page is not working. It showing empty. And I am facing following 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.
Initially I have this issue for every single webview. I search this error in Google then i found I need to add above code in my .plist file. I done that after that other pages working FaceBook page not working.
Note: I am reading Facebook link from Localizable.strings file like this.
var url = NSLocalizedString("facebook_link", comment: "");
let requestURL = NSURL(string:url)
let request = NSURLRequest(URL: requestURL!)
webView.loadRequest(request)