Skip to content

App URL

The app URL isn’t technically a widget, but it talks to the platform in exactly the same way. We cover the basics of this page in Install process, so here we focus on the events you can send back to the platform with postMessage.

App URL widget

These are the parameters we send along with the URL, for example https://example.app?action=open.

  1. action: open, install or uninstall.
  2. authtoken: only sent if the app is installed.
  3. admin_id: the unique identifier of the administration.
  4. chain_id: 0 by default, unless the administration is part of a chain.
  5. app_id: the unique identifier of your app.
  6. lang: the user’s language.

This widget supports only the height event. This is the complete event object:

{
height: 300 // height in pixels
}

You’ll want to avoid your widget showing a scrollbar or a lot of white space. To fix this, set the widget height by sending it in an event:

window.top.postMessage({
height: 300 // height in pixels
}, '*') ;

Sometimes a fixed height doesn’t work, because the height depends on the content. In that case you can do something like this, so the widget height updates whenever the size of your application changes:

const updateSize = () => {
window.top.postMessage({
height: document.body.scrollHeight // height in pixels
}, '*') ;
}
updateSize() ; // set the height for the first time
// watch for size changes and update the height when they happen
// create an observer instance to check if the screen changes
const resizeObserver = new ResizeObserver((entries) => {
updateSize() ;
})
// start observing a DOM node
resizeObserver.observe(document.body)

Our basic apps already include this feature. You’ll find them in the tutorials section.