1

我正在使用 AngularJs 入门应用程序进行 phonegap 并在 Android Phone (4.03) 上进行测试。应用程序启动正常,接收到的事件中的以下代码运行并正确路由视图。没有发生的是我添加的通知警报

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);
}
};
4

1 回答 1

1

您需要为您的警报添加回调 -

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

那应该工作...

于 2013-10-07T14:47:51.220 回答