iOS Question Allow file access for webview in iOS [Solved]

AneeshJay

Member
Licensed User
Hi guys,

In B4A ,I enable local storage in webview using the following,

B4X:
Dim jwb As JavaObject = wb
    Dim jset As JavaObject = jwb.RunMethod("getSettings", Null)
    Dim r As Reflector
    r.Target = jset
   
    ' Enable local storage
    r.RunMethod2("setDomStorageEnabled", True, "java.lang.boolean")
    ' Disable cross-origin limits on File protocol
    r.RunMethod2("setAllowFileAccess", True, "java.lang.boolean")
    r.RunMethod2("setAllowFileAccessFromFileURLs", True, "java.lang.boolean")
    r.RunMethod2("setAllowUniversalAccessFromFileURLs", True, "java.lang.boolean")

I want to set the equivalent fields(or achieve the equivalent) to the above in B4i that allows file access. Any help on this is much appreciated.

Sources online suggest doing something like,
Objective-C:
wkwebview.configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")

I'm guessing that the above can be done using native object, but I'm not sure how. Can anyone please help me?
 
Last edited:
Solution
This is the equivalent call:
B4X:
WebView1.As(NativeObject).GetField("configuration").GetField("preferences").SetField("allowFileAccessFromFileURLs", True)

I don't know whether it really works or not.
Top