Forum

Dinkel
Moderator
    Has successfully completed the online course Introduction
    Has successfully completed the online course Intermediate (200)
    Has successfully completed the online course Advanced (300)
    Has successfully completed the online course Basics (100)
5 years, 9 months ago #19490
Up
2
Down
::

You have to bind this.

document.addEventListener("backbutton", onBackKeyDown.bind(this), false);

function onBackKeyDown() {
    var curr_page = sap.ui.getCore().byId("Application").getCurrentPage();
    console.info(curr_page.getId());
    if (curr_page.getId() === "PAGE1") {
        console.info('close pressed');
        window.navigator.app.exitApp(); // OK
    } else {
        console.info('back pressed');
        // window.navigator.app.backHistory(); // <no action
        this.navBack(); // Uncaught TypeError this.navBack is not a function
        // window.navigator.app.navBack();  // Uncaught TypeError window.navigator.app.navBack is not a function
    }

}