MikeW
MikeW

Reputation: 4809

Unable to get Phonegap notifications working using AngularJs

I'm using an AngularJs starter app for phonegap and testing on an Android Phone (4.03) . The app starts up fine and the following code in the received event runs and correctly routes the views. What isn't happening is the notification alert I've added

var app = {
initialize: function() {
    this.bindEvents();
},
bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
    app.receivedEvent('deviceready');
},
receivedEvent: function(id) {
    var parentElement = document.getElementById(id);
    var listeningElement = parentElement.querySelector('.listening');
    var receivedElement = parentElement.querySelector('.received');

    listeningElement.setAttribute('style', 'display:none;');
    receivedElement.setAttribute('style', 'display:block;');


    //the next 2 calls to navigator.* don't do anything

    navigator.notification.alert(
        'You are the winner!',  // message
        'Game Over',            // title
        'Done'                  // buttonName
    );
    navigator.notification.beep(2);


    console.log('Received Event: ' + id);
}
};

Upvotes: 1

Views: 777

Answers (1)

Drew Dahlman
Drew Dahlman

Reputation: 4972

You need to include a callback for your alert -

 navigator.notification.alert(
        'You are the winner!',  // message
        callbackFunction,       // Callback
        'Game Over',            // title
        'Done'                  // buttonName
    );

That should work...

Upvotes: 1

Related Questions