Finding the Notch Height

In my Android game, the energy bar appears behind the front camera.

Is there a way to determine the height of the notch? This way, it would be possible to adapt the game to every type of mobile screen.

I searched the forum, and it seems possible through a Cordova plugin. But I wouldn’t know where to start!

I asked ChatGPT, and it wrote this code. I’m using it, but without any result. Is it correct?

The code reads the screen and creates two global variables to use for positioning the header.

function getNotchSizes(runtimeScene) {
    const viewport = window.visualViewport;
    const windowHeight = window.innerHeight;

    // Altezza barra superiore (notch)
    const topInset = viewport.offsetTop || 0;

    // Altezza barra inferiore (gestures bar o notch in basso, se presente)
    const bottomInset = windowHeight - (viewport.height + topInset) || 0;

    // Imposta le variabili globali in GDevelop per memorizzare queste dimensioni
    runtimeScene.getGame().getVariables().get("NotchTopHeight").setNumber(topInset);
    runtimeScene.getGame().getVariables().get("NotchBottomHeight").setNumber(bottomInset);
}

// Chiama questa funzione all'inizio della scena o quando necessario, passando `runtimeScene`
getNotchSizes(runtimeScene);