How to use `cordova-plugin-universal-links` to create universal link for cordova app
-
I’m developing a cordova app using quasar framework and I’m trying to add universal link to the app using
cordova-plugin-universal-links
. Here is the documentation: https://github.com/eldadfux/cordova-plugin-universal-links. This plugin export an moduleuniversalLinks
to help subscribe universal link event.
However, I’m not sure how to subscribe event using universalLinks module. I was trying to add codes like this:<template> ...some html code... </template> <script> // import { universalLinks } from 'cordova-plugin-universal-links' export default { name: 'default', components: { }, data () { return { } }, mounted () { var app = { // Application Constructor initialize: function () { this.bindEvents() }, // Bind Event Listeners bindEvents: function () { document.addEventListener('deviceready', this.onDeviceReady, false) }, // deviceready Event Handler onDeviceReady: function () { console.log('Device is ready for work') // window.universalLinks.subscribe('openApp', function (eventData) { universalLinks.subscribe('openApp', function (eventData) { console.log('openApp.') // do some work to show list of news }) } } app.initialize() // await this.$store.dispatch('common/loadPredefinedScreens') } } } </script>
https://quasar.dev/quasar-cli/developing-cordova-apps/cordova-plugins
Here is the quasar documentations for using cordova plugins. However, when I try to run and build the app, it post an error sayinguniversalLinks
not defined, and then I tried to usewindow.universalLinks
but it does not work either. According to quasar documentation, cordova module should be injected intowindow
, but it does not work.
Anyone can help to tell me how quasar framework usescordova-plugin-universal-links