iOS Question HTML5 wrapper problem

Jack Cole

Well-Known Member
Licensed User
Longtime User
I am trying to write a wrapper for an HTML5/javascript app in b4i similar to what I did previously in b4a. The trouble is that it does not load appropriately. It seems to be related to not being able to load files in subdirectories under the assets folder.

I have worked around this in the past by zipping the html5 app and extracting it to file.dirtemp before loading it in the webview. Doing that works, but it is not desirable to do this.

I have attached my project, which loads the html5/js app only partially. Any ideas on what I'm doing wrong?
 

Attachments

  • wrapper.zip
    145.3 KB · Views: 313
Last edited:

Jack Cole

Well-Known Member
Licensed User
Longtime User
Sorry, I guess the create zip feature doesn't include subfolders of the Files folder. I have attached a simpler example. I made a very simple HTML file and put it in the subfolder resources in the Files folder. I try to load test.html from there, but it won't load.

I'm trying to load the file this way:

B4X:
WKWebView1.LoadUrl(WebViewAssetFile("/resources/test.html"))

The pagefinished event is triggered with success=false, and nothing loads in the webview.
 

Attachments

  • html5wrapper.zip
    2.9 KB · Views: 323
Upvote 0

Jack Cole

Well-Known Member
Licensed User
Longtime User
I understand. Please consider adding this ability. Normally, it wouldn't be a problem for me. I have an app built with Cordova that I want to replace with a B4i hybrid app. Not being able to access subfolders in the default assets folder may prevent me from being able to do that (it would change the domain of the javascript localstorage causing the app to lose saved data). I'll try to see if there are any workarounds.
 
Upvote 0

Jack Cole

Well-Known Member
Licensed User
Longtime User
That is what I am doing. I have explored my concern with the javascript localStorage, and have discovered it is not an issue. Even though the web app will be running from a different folder, it can still access all the same data. It looks like the browser treats everything under file:// as being in the same domain. That is a relief. Thanks Erel for your help.
 
Upvote 0
Top