[SOLVED] f7Vue Do something before framework7 app init()

Hullo . team,

I am stuck. I am working on app on which I have to make sure they have allowed Location permission before going on to init the app.

perviously in core, i have been able to do this like so…

var app = new Framework7({ init: false; });

document.addEventListener('deviceready', () => {
 //do stuff here...
 //Later
  app.init();
}, false);

I can’t seem to find a way to go about this… as the Vue instance is executed on the fly, and the only option am left with is to rely on the app’s main app component.

data() {
        return {
            f7params: {
                id: 'com.xxxx.app', 
                name: 'App Name', 
               
                //disable app init here
                init: false,
            },
        }
    },

 mounted() {
        this.$f7ready((f7)  =>  {
             const app = f7;

             /*tried app.init(), but failed*/

            // Init cordova APIs
            if (app.device.cordova) {
                cordovaApp.init(app);
            }
        });
      }

How do I go about it in Vue? Thanks in advance

@nolimits4web, @pvtallulah

Hi max
Try like this

document.addEventListener(‘deviceready’, () => {
new Vue({…})
}, false)

@pvtallulah, thank bro… I tried that first but it definitely will fire straight after the event is fired. I sort of want to make sure the permission is given and location enabled before showing anything in the app.

In core, i would use app.init() later after doing my stuff.

I have an external variable that I import and give the app instance… I am supposed to give it the Vue instance, save it to some local variable, do stuff, and when I am done with everything, I call that local variable (it now has the instance), and it kickstarts the app.

const app = new Vue();

document.addEventListener('deviceready', LocationSettings.init(app), false);

ok, so wait for deviceReady, then call the Location permision. and if it yes, load vue if not, alert(‘some text’)

document.addEventListener('deviceready', askLocationPermission, false);

function askLocationPermission (e) {
  //ask here, 
  hasPermision()
  .then(res => {
    if (res) { const app = new Vue(); LocationSettings.init(app); }
    else alert('your text')
  })
  .catch(err => { alert('something went wrong: ' + err) })
}

if this donst work to you, i will try to do a small app with permission location and f7 init false. Since you say f7 init dosnt work for you, all my advices are trying to avid that path.

1 Like

Just don’t do it! Don’t delay app initiliazation. Why do you really need it? Why do you need to ask permission before app init?

1 Like

@nolimits4web, I am trying to enforce users to allow us to use the highest accuracy location using this plugin, as the app needs to access device location to actually go about its core business.
If users deny this, then the app won’t really have a meaning, because we can’t really help them. we need to watch their location whenever they are using the app so we help them based on their location.

Then you init the app still. If no location permission granted you show some default page saying location need to be enabled and show permission request dialog. Then, if permission granted, you page/view to what you need

Awesome! This actually looks more brilliant and overly better. Thanks so much @nolimits4web