Hi all.
I’ve just added the post message code to my web app with this code: ThunkableWebviewerExtension.postMessage(xmlText);
but nothing happens:
blocks:
<!DOCTYPE html>
<html>
<head>
<script
src="https://thunkable.github.io/webviewer-extension/thunkableWebviewerExtension.js"
type="text/javascript">
</script>
</head>
<script>
const textData = "This is from my page";
ThunkableWebviewerExtension.postMessage(textData);
});
</script>
</html>
See if this works then you know it is not the extension. If you save if to .html file and call it from your web viewer it should give you the result in the receive message event.
Hi @muneer i got this error message in console while debugging:
Uncaught DOMException: Failed to execute 'postMessage' on 'Window': HTMLUnknownElement object could not be cloned.
at Object.postMessageToWebview [as postMessage] (https://thunkable.github.io/webviewer-extension/thunkableWebviewerExtension.js:6:21)
at HTMLDocument.<anonymous> (https://cdpn.io/lukeplays33/debug/eYvJBEa/WPALYROwJVwk:532:33)
at n (https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:14784)
at Object.fireWith (https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:15553)
at Function.ready (https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:9773)
at HTMLDocument.B (https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2:14348)
When you copy anything from the community posts, check the quotation marks, the community app converts them to accented marks while development environments expects simple quotations.
This could be a reason that prevents your .html file from being processed correctly.