Run Quasar in quasar dev mode when using cordova - issues



  • Hello,

    I am a bit confused on this.
    When you use Cordova there are events that are set on the app start.
    The problems comes when you try to run your app in “quasar dev” mode in your pc browser, Chrome does not like it as it does not recognise the Cordova event and therefore crashes the app.

    How can I get around this please? Here are some events I use:

    document.addEventListener('deviceready', this.onDeviceReady, false);
        document.addEventListener('offline', this.onOffline, false);
        document.addEventListener('online', this.onOnline, false);
        document.addEventListener('pause', this.onPause, false);
        document.addEventListener('resume', this.onResume, false);
        document.addEventListener('menubutton', this.onMenuKeyDown, false);
        document.addEventListener('backbutton', this.onBackKeyDown, false);
    

    I would really like to test some of my app in the browser quickly because sending the app to the mobile each time takes time.

    Thanks



  • @bambinou where did you register these events? It should be inside the export defaults ie. inside mounted hook since you are referencing this on your callbacks.



  • I added them inside a mounted hook in my App.vue.

    I have found a way to do it:

        if (this.$q.platform.is.cordova) {
          document.addEventListener('deviceready', this.onDeviceReady, false);
          document.addEventListener('offline', this.onOffline, false);
          document.addEventListener('online', this.onOnline, false);
          document.addEventListener('pause', this.onPause, false);
          document.addEventListener('resume', this.onResume, false);
          document.addEventListener('menubutton', this.onMenuKeyDown, false);
          document.addEventListener('backbutton', this.onBackKeyDown, false);
        }
    

Log in to reply