It is possible to store data on the Android Webview Window Object at start with Capacitor/Ionic? #7384
-
I have some configuration variables that depend on which flavor the Android App is using, including some auth variables that are needed for the angular app start up. I need to write some of that data into a global const in the window object, but I do not find any way to do it. I have tried creating a Capacitor Plugin and calling override fun load() {
this.bridge.webView.evaluateJavascript("const __myTest = 'hello world'", null);
} or with override fun handleOnStart() {
super.handleOnStart()
this.bridge.webView.evaluateJavascript("const saninn = 'hello saninn'", null);
} But even when that part is called, it does not set anything (probably the webview is not defined at that time) Is this even possible? I do not want to define a plugin call because I would need to change all the initialization of the app and I am trying to prevent that. I am assuming there should be a way to do this because at the start the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It should be possible, but you can't create it as a |
Beta Was this translation helpful? Give feedback.
Looks like some threading issue, it works if you use
this.bridge.eval("window.saninn = 'hello saninn';", null);
, which runsevaluateJavascript
under the hood, but on main thread.