1

This is a question and a rant

I have to get temperature readings from an andriod app written in ionic angular to a webpage written apache wicket... No, I don't have any control over either stack.

The kicker is the wicket app isn't even run properly attached to a domain, it's just run from a box at the client and then the client machines connect through <server ip>:8080/appname

Which means I can't solve my problem by simply having the website and app on the same domain and then use local storage...

I have tried

Ionic
window.postMessage({ type: 'temperatureData', data: tempFormatted }, '*');

Test it from this page
<!-- index.html (web page) -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Page</title>
</head>
<body>

<h1>Temperature Data</h1>
<p id="temperatureData">Loading...</p>

<script>
// Listen for messages from the Ionic app
window.addEventListener('message', (event) => {
if (event.data.type === 'temperatureData') {
// Update the temperature data on the page
document.getElementById('temperatureData').textContent = event.data.data;
}
});
</script>

</body>
</html>

Which does not work, the page fails to pick the data.

So my rant is the situation. M question is does anyone have any ideas?

Comments
  • 0
    From MDN it mentions that you have to match the scheme, hostname, AND port in the targetOrigin option and doesn’t recommend using just “*”. That and maybe your reference to your target window is not correct? 🤷‍♂️
  • 0
    How much data is there? Can you squeeze it in base64 into less than 16 query strings? Can your app embed a frame of the website that loads without user interaction?
  • 0
    I don't know anything about this stack so I'm trying to think of solutions that pretty much always work.
  • 0
    from iframe window.top.postMessage('foo', '*')

    because you post message to parent window
  • 0
    @lorentz they data is a number with one decimal. So like 21.1 for example. As for embedding a frame, I'm not sure. Limits I'm working with are that the app has to be an installed app and the webapp is always run through Airlock Browser
  • 1
    @shovethisrant Interesting, thank you. I'll look into this
  • 1
    @TheBeardedOne Any mobile browser should have an intent for opening a URL. Try finding this intent and use it to open some special receiver page while passing the number in the query string.
Add Comment