简体   繁体   中英

Failing to navigate App from Capacitor listener (appUrlOpen) event (Nuxt, Vue.js, Vue-Router)

As a first project I have Nuxt, VueJs and Capacitor that fails to route a Firebase dynamic link.

The iOS App is setup to accept Associated Domains as works as such.

The iOS App opens and fires a Capacitor event 'appUrlOpen', however it fails to navigate when I try initiate router.push() to any valid path eg.('/about')

Debugging suggests the promise on the push succeeds, however this is not reflected on the simulator.

I have ensured that the the routes are correct at the time of the push and exhausted all other possibilities to where this may be causing an issue.

The code below resides in a JS file which is imported as a plugin with nuxt.config.js

import { App } from '@capacitor/app';
import Vue from 'vue';
import VueRouter from 'vue-router';

const router = new VueRouter({ routes: [ { path: '/about' }] });

App.addListener('appUrlOpen', data => {
    router.push({ path: '/about' })
      .then(() => console.log('Navigated!'))
      .catch(error => {
      console.log('Error', error);
    });
});

Oddly, a user by the name of Mani Mirjavadi (user:4448220) indirectly answered this question but removed his post a short while ago. Luckily it was available as a cached resource.

It appears as if the route needs to route as such below.

 window.onNuxtReady(() => {
    App.addListener('appUrlOpen', (event) => {
        window.$nuxt.$router.push('/community')
        })
    })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM