I have webview working fine for version less then ios9, but seems not working for ios9, and its shows me a blank page, but the url is passed.
-
its working fine.but taking time to open web page. once update your code . – Uma Madhavi Oct 06 '15 at 10:19
-
In iOS 9 apple made it, by default, refuse all connections not using TLS 1.2. Most likely this is your issue. You should read the iOS 9 release notes and investigate this. If its possible to upgrade the server (if its under your control) – Simon McLoughlin Oct 06 '15 at 10:20
-
@Uma mine its not even opening after waiting a long time. – M.Almeida Oct 06 '15 at 10:26
-
@SimonMcLoughlin i'll read the notes then. – M.Almeida Oct 06 '15 at 10:26
-
@M.Almeida check by replacing weburl – Uma Madhavi Oct 06 '15 at 10:27
-
@Uma Already did it, not working – M.Almeida Oct 06 '15 at 10:30
-
NSURL *url = [NSURL URLWithString:@"http://www.apple.com/"]; NSURLRequest *req = [NSURLRequest requestWithURL:url]; [self.webView loadRequest:req]; – Uma Madhavi Oct 06 '15 at 10:32
-
URL is updated , but its still blank – M.Almeida Oct 06 '15 at 10:42
2 Answers
To configure a per-domain exception so that your app can connect to a non-secure (or non TLSv1.2-enabled secure host), add these keys to your Info.plist (and note that Xcode doesn’t currently auto-complete these keys as of the first Xcode 7 beta seed):
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
There are other keys that you can use to configure App Transport Security as well, such as:
NSRequiresCertificateTransparency
NSTemporaryExceptionRequiresForwardSecrecy
NSTemporaryThirdPartyExceptionAllowsInsecureHTTPLoads
NSTemporaryThirdPartyExceptionMinimumTLSVersion
NSTemporaryThirdPartyExceptionRequiresForwardSecrecy
For Demostration you can do like that as shown in following image:
But What If I Don’t Know All the Insecure Domains I Need to Use?
If your app (a third-party web browser, for instance) needs to load arbitrary content, Apple provides a way to disable ATS altogether, but I suspect it’s wise for you to use this capability sparingly:
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
You can find its Tech Note Here
- 2,530
- 13
- 36
You may want to check the order of updating url and rendering page. In ios9, url will not be changed immediately, even if you directly assign value to it.
So you can try to set a timeout to wait until url updated.
updateUrl();
window.setTimeout(function(){
renderPage();
},30);
sometimes set timeout to 0 would do the trick, because it forces the code runs in the next event loop.
- 372
- 3
- 10