Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48983

Reference Vue store from Capacitor listener

$
0
0

Hello,

I have a Vue js app and I am using a Capacitor plugin to capture an event in the application - “appUrlOpen” by defining a listener.
This works well and is defined as below : -

In my User.vue

<script>
import { Plugins } from "@capacitor/core";
const { App } = Plugins;
.
.
beforeCreate() {
    if (isPlatform("hybrid")) {
      App.addListener("appUrlOpen", function (data) {
        console.log("Inside listener works well : " + data.url);
        this.$store.dispatch("setUrl", data.url);
      });

    }

  },
.
.
</script>

Now the problem is I am not able to get hold of the $store as it is always undefined, which means my ‘this’ is not referencing to my Vue app.

How can I update the values in the Vue store from within the listener function ?

Thank you.

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>