iosxamariniframewkwebviewfile-uri

How to load local file via iframe inside html file in wkwebview?


I am migrating UIWebView to WKWebview. While I could manage to migrate most of the workflows. I am stuck at one workflow that I am not able to load the local file ("file://") via iframe from the html file in WKWebview. It was working fine in UIWebView.

Also if iframe source is "web-url" and not local, it is working fine.

I am not seeing any error or any message on the console.

I read on few thread that loading local data in iFrame is broken in WKWebView, most probably because "allowReadAccesstoURL" setting which i am passing for main html is not passed to iframe correctly.

I wanted to check if there is a way to load local file via iframe.

It is disappointing that Apple has broken the functionality without providing proper alternative.


Solution

  • I am finally able to resolve it. Issue was that the readAccess path for the "LoadFileUrl" was not inclusive of the url that was being loaded as iframe.

    What was irritating is that console log did not give out any detail related to the error and I was not seeing any network call like decidepolicy or anything for the iframe loading, which caused the confusion.