Search code examples
cordovasencha-touchsencha-touch-2cordova-2.0.0

Sencha Touch 2 : Getting error while displaying simple alert message using cordova


BackGround : I have developed a SenchaTouch application using sencha 2.1. Now I am trying to display a simple alert message using cordova 2.2.0 js.

My basic doubt is "Can I show the alert box using 'navigator.notification.alert' on google chrome or I have to run it on emulator to see the alert box?"

I have followed below steps.

  • Included cordova 2.2.0 js in my workspace and referred it from index.html. I am able to see the file loaded in the Google Chrome's Network Tab.

  • Below is my code which simply displays the native alert box on a button click.

    alertDismissed : function() {
        console.log('This function is called');
    }
    
    onLoginNoteCommand: function () {
    
        console.log('onLoginNoteCommand');
    
        navigator.notification.alert(
            'Please Select a Car',  // message
             this.alertDismissed,         // callback
             ' '            // title
         );
    }
    

Error Occurred

I am getting "Uncaught TypeError: Cannot call method 'alert' of undefined " Error.

Any ideas Where I am doing it wrong?

Thanks


Solution

  • When I integrated my code with PhoneGap and ran it on device, I am able to see the native alert boxes. So, my findings for above sollution is you can use navigator object only on devices after integrating it with PhoneGap and not on browser.

    Thanks