iOSHTMLViewer - basic app not working

Good evening. I’ve starting playing with the iOS side of Xojo this past week and was trying to build a simple web browser using the iOSHTMLViewer. I am wondering if I’m overlooking something simple.

I’ve created the app, added a button, a text field, and the HTML viewer. When running in the simulator and on my iPhone I get odd results. I can see local content created on the device, but I can not open any webpages on the Internet.

Below is an example of the code in the buttons Action Event:

'Removed the input field from the equation for troublehsooting. Currently nothing is loading when referencing sites on the net.
'WebViewer.LoadURL(URLField.Text)

'Create a local HTML file and open it.
'So far this loads the local file content but if I click on the link I get nothing
Dim html As Text = “Hello!
<A HREF=”“http://www.cnn.com”">CNN
<iframe src="“http://www.cnn.com”">
Final Line"

Dim htmlFile As FolderItem = SpecialFolder.Documents.Child(“hello.html”)
Dim output As TextOutputStream
output = TextOutputStream.Create(htmlFile, TextEncoding.UTF8)
output.WriteLine(html)
output.Close

WebViewer.LoadURL(htmlFile.URLPath)

The comments are there because I was making notes as I played around. I can see the word “Hello!”, the link to CNN, and then an empty iframe, followed by the “Final Line” text. That lets me know the HTMLViewer is processing the local file.

If I just send it the text of the URL entry field, nothing appears. If I click on the “CNN” link in the locally generated file, nothing happens. If I hold down and choose the option to open the link, nothing happens.

Is there a sandbox/safety setting/some other obvious thing that I’m missing that I need to doc to view internet pages? This is happening with both the simulator and with the app loaded to my personal phone.

BTW, this is with Xojo 2016 Release 2.

Thanks,
Eric

Have you tried calling LoadUrl with the CNN url directly?

There seems to be an issue with HTMLViewer in iOS : no matter which method and which site, nothing displays when it is on the Internet :confused:

It is a rather sad bug. <https://xojo.com/issue/44647>

Surprising nobody spotted it before.

Solution : use 2016R1.1.

@Michel Bujardet
Add this plist to your project and it will work

[code]<?xml version="1.0" encoding="UTF-8"?>

NSAppTransportSecurity NSExceptionDomains xojo.com NSIncludesSubdomains NSTemporaryExceptionAllowsInsecureHTTPLoads [/code]

[quote=277696:@Antonio Rinaldi]@Michel Bujardet
Add this plist to your project and it will work

<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> [/quote]

Let me see : does seriously Xojo iOS prevent any communication that is not secure ?

Yes
But you can declare you want to use http connection and be prepared to explain the reason

[quote=277709:@Antonio Rinaldi]Yes
But you can declare you want to use http connection and be prepared to explain the reason[/quote]

That’s yet another one of those Apple dictates ? An immense majority of sites are not SSL able.

I can understand the HTTPSocket https requirement, but that for an HTMLViewer is just plain ridiculous.

If you have to load generic pages (as for Eric’s original example)

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

Yes- Apple’s iOS SDKs are now secure/https by default, unless you opt out.

[quote=277722:@Antonio Rinaldi]If you have to load generic pages (as for Eric’s original example)

<dict> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> </dict> [/quote]

Thank you Antonio.

That promises a lot of hurt :confused:

Greg:

I did try calling LoadURL with the CNN site directly. Nothing. Blank. I’m going to look at the security/plist options and see if that fixes this at least temporary. I don’t have anything yet that actually requires iOSHTMLViewer yet but I do have some ideas that I wanted to start playing with.

Thanks for the responses.

Eric

@Antonio Rinaldi The plist information allowed me to be able to continue playing with the HTMLViewer. Thanks!

As it was put to me, many developers use htmlviewer type controls for logins and such and claim that they are secure, but the end user really has no way to know. This just makes it so developers have to go out of their way to do something stupid.