Search code examples
javascriptandroidcordova

How to use navigator.app.exitApp() after navigator.notification.alert


receivedEvent: function (id) {
    if (navigator.connection.type == Connection.NONE) {
        navigator.notification.alert('NO NETWORK CONNECTION', null, 'Warning', 'OK');
        }
        else {
            window.open('my_web_site', '_self');
        }
}

how close aplication after button OK


Solution

  • You can use the confirm method instead of alert to show a message.

    receivedEvent: function (id) {
        if (navigator.connection.type == Connection.NONE) { 
            navigator.notification.confirm("NO NETWORK CONNECTION", function(e){navigator.app.exitApp();}, ["Warning"], ["Ok"])
        }
        else {
            window.open('my_web_site', '_self');
        }
    }