Search code examples
angularionic-frameworkionic3cordova-pluginsionic-native

Angular - trying to use deeplinks but only the app is opening, routing not working


I'm trying to use deeplinks but only the app is opening. The routing is not working.

Here is my code:

import { Component, ViewChild } from ‘@angular/core’;
import { App, Platform, Nav, NavController } from ‘ionic-angular’;
import { StatusBar } from ‘@ionic-native/status-bar’;
import { SplashScreen } from ‘@ionic-native/splash-screen’;
import { Deeplinks } from ‘@ionic-native/deeplinks’;
import { HomePage } from ‘…/pages/home/home’;
import { HarryPage } from ‘…/pages/harry/harry’;

@Component({
    templateUrl: ‘app.html’
})

export class MyApp {
    @ViewChild(‘myNav’) nav: Nav;
    rootPage:any = HomePage;

    constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,private deeplinks: Deeplinks) {
        platform.ready().then(() => {
            statusBar.styleDefault();
            splashScreen.hide();
        });
        this.deeplinks.routeWithNavController( this.nav, {
            ‘/harry’: HarryPage,
            ‘/’ :HomePage
        }).subscribe( (match)=>{
                console.log(match.$route);
                // alert(JSON.stringify(match))
            }, (noMatch)=>{
                // alert(JSON.stringify(noMatch));
            })
    }
}

Whenever I try to access the /harry route, only the home page is opening.


Solution

  • its working if you put same code inside root-page, if you follow their documentations then nothing going to work.