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.
问题:
回答1:
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:
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.