iOS Question Webview no display

Petertsgtongerlo

Member
Licensed User
Longtime User
Hello,

I'm using the following code in b4i 8.00 to link to a website aftrer pressing a button in my app:

Public UrlWebsite As String
Public WebView1 As WebView

UrlWebsite = "http://www.nu.nl"
WebView1.LoadHtml(UrlWebsite)


the only thing I see is http://www.nu.nl on my phone, thats's it, not de website itself, what am I doing wrong?
 

BillMeyer

Well-Known Member
Licensed User
Longtime User
As @Pendrush says (in his link) as well as:

Webview1.LoadHtml(UrlWebsite) means that you have to have the HTML either as a string or in your assets folder. What you should be using is:

WebView1.LoadUrl(UrlWebsite) and also when I click on the link you have given, I get :
upload_2018-6-4_11-22-5.png
you can see that it is actually "https", so at the end of the day you need:

B4X:
UrlWebsite = "https://www.nu.nl"
WebView1.LoadURL(UrlWebsite)

and your problem should be solved.

Enjoy !!
 
Upvote 0

BillMeyer

Well-Known Member
Licensed User
Longtime User
Have you done this.

If you want to show non-secure pages in WebView and allow the user to navigate to other domains as well:
Code:
#PlistExtra: <key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><true/>
#PlistExtra: <key>NSAllowsArbitraryLoadsInWebContent</key><true/>
#PlistExtra: </dict>
Note that NSAllowsArbitraryLoads is true this time. NSAllowsArbitraryLoadsInWebContent is only applied on iOS 10+. When it is applied it cancels NSAllowsArbitraryLoads.
Apps with this key require a justification: https://developer.apple.com/library...Keys.html#//apple_ref/doc/uid/TP40009251-SW59

Another option which is relevant if you are targeting iOS 9+ is to use SafariController from the iUI9 library.

SafariController is a powerful embedded browser: https://www.b4x.com/android/forum/threads/iui9-safari-controller.70552/#content
SafariController can access all pages. No need to add any exclusion.

I have just checked both your URL's and they both work as is - BUT - under Main and #Region Project Attributes I have this above included. You need to tell iOS that it is OK to look at non-secure websites.

Full Story Here

Enjoy !!
 
Upvote 0
Top