I have Recieving set to always enabled, and I configure the blocks to set the message received into a json object and to webviewstring. and I'm checking for change in value for webviewstring.
However when I receive messages there is no alert popped up that a string has been set to webviewstring
let lastValue = "";
function checkWebViewString() {
if (window.AppInventor.getWebViewString() !== lastValue) {
lastValue = window.AppInventor.getWebViewString();
onWebViewStringChanged(lastValue);
}
}
function onWebViewStringChanged(newValue) {
console.log("WebViewString changed:", newValue);
// do whatever you want with the new value
alert(newValue)
}
// Start polling every 300ms
setInterval(checkWebViewString, 300);
If your app is in the background, then the event MessageReceived does NOT get triggered, you get a notification instead...
To get the notification you need post notifications permission