HTML Extension not Recieving POST messages from App in Android and Live Test

Hi Community,

My HTML Extension is not Receiving Post Messages in Android, even though it is working in Web Preview.
Tried asking ChatGPT but it did not helped
Code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Whoocoder's image downloader</title>
</head>
<body>

<script 
      src="https://thunkable.github.io/webviewer-extension/thunkableWebviewerExtension.js"
      type="text/javascript"></script>
<script>
// Receive message from Thunkable app
ThunkableWebviewerExtension.receiveMessage(function(message) {
    console.log("Received message from Thunkable app:", message);
    // Define the downloadImage function
    function downloadImage(imageUrl) {
        fetch(imageUrl)
        .then(response => response.blob())
        .then(blob => {
             // Create a URL for the image blob
             var url = window.URL.createObjectURL(blob);
             // Create a link element
             var link = document.createElement("a");
             link.href = url;
             link.download = "IMAGE_DOWNLOADED_BY_A_THUNKABLE_APP"; // Name of the downloaded file
             // Append the link to the body and trigger a click event
             document.body.appendChild(link);
             link.click();
             // Clean up
             document.body.removeChild(link);
             window.URL.revokeObjectURL(url);
        })
        .catch(error => {
            console.error('Error fetching image:', error);
            alert("Failed to download image. Please check the URL and try again.");
        });
    }
    // Call downloadImage function with the received message (image URL)
    downloadImage(message);
});
</script>
   
</body>
</html>

Do I have to Update code to remove this issue?
Please help me with this.

Thanks

Could someone Please Reply?

Hi @whoocoder, as we’ve discussed elsewhere, writing these scripts is beyond our normal scope of support but hopefully someone else in the Community has experience writing scripts and can help out!

1 Like

Yes, that’s why posted the issue here.