Sunday, December 13, 2015

Fixing iOS 9 (9.1,9.2) Blank uiWebView Page in a Corona App

As expected, an update has come along that breaks something in your Corona app... this particular issue has to do with changes in iOS 9 uiWebView security. If you are not connecting your webview via (valid) https, you will now get a blank  page in your webview. This can be resolved by customizing App Transport Security settings in info.plist (for native apps). This file won't exist in your Corona project, but it is supported via the build.settings file. There is a Corona forum post on how to update build.settings to generate the necessary info.plist settings in your build here. Even better, there is a Corona blog entry with more insight here. Finally, if you want to truly understand your settings, reference the Apple docs on this here.

In the end, your build.settings will need an exception added like so:

settings = { iphone = { plist = { NSAppTransportSecurity = { NSExceptionDomains = { [""] = { NSIncludesSubdomains = true, NSThirdPartyExceptionAllowsInsecureHTTPLoads = true }, }, }, }, }, }

If you control the domain, you should use NSExceptionAllowsInsecureHTTPLoads rather than NSThirdPartyExceptionAllowsInsecureHTTPLoads. Only use NSIncludesSubdomains if you need to allow multiple subdomains.

Of course, the ideal solution is to ensure any webview is connecting via a valid https connection... but that is not always possible.