phonegap navigator.notification.alert doesn't work

后端 未结 6 1077
时光说笑
时光说笑 2021-01-02 01:48

The title is self explanatory, I ca\'t figure out why tho.

sources: www/index.html:



    
        

        
6条回答
  •  Happy的楠姐
    2021-01-02 02:15

    You will only see working from the android emulator or a device, in ripple does not work.

        var app = {
        // Application Constructor
        initialize: function() {        
            document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
        },
    
        // deviceready Event Handler
        //
        // Bind any cordova events here. Common events are:
        // 'pause', 'resume', etc.
        onDeviceReady: function() {
            //this.receivedEvent('deviceready');
                console.log(navigator.notification);
    
                navigator.notification.alert(
                        'You are the winner!',  // message
                        alertDismissed,         // callback
                        'Game Over',            // title
                        'Done'                  // buttonName
                    );
                //navigator.notification.beep(2);
        },
    
        // Update DOM on a Received Event
        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;');
    
            console.log('Received Event: ' + id);
        }
    };app.initialize();
    

提交回复
热议问题