-
Notifications
You must be signed in to change notification settings - Fork 940
Closed
Description
Hello,
I can listen to post messages on browser like this but I didn't quite understand how I can set a local variable to event.data.
String script1 = 'window.addEventListener("message", receiveMessage, false);' +
'function receiveMessage(event) {console.log(event.data);}';
widgetWebview.evalJavascript(script);
I tried
String script2 = 'var test = "Hello, World!";'+
'function getMessage(val) {return val;}' +
'getMessage(test);';
var testLocal = await widgetWebview.evalJavascript(script2);
and you can set testLocal to test but I couldn't apply it to post message.
Also, I tried setting value of test inside script1 and trigger onUrlChanged inside receiveMessage function and access it from script2. The variables in script1 were not accessible by script2.
Can we use a callback function to communicate between app & webview?
Thanks
Metadata
Metadata
Assignees
Labels
No labels