deep links not working - ionic
Asked Answered
A

1

3

im using deeplinks and ionic 3, but the url i created not working.

this is the url : https://lucky.com/prd/rm74fEgBB2frzhagYcov

this is my code :

this.deepLinks.route({
      '/prd/:id': ProductDetailsPage,
      '/rcm/:id': RecommendationDetailsPage
    })
    .subscribe((match) => {
      console.log(match);
    }, (nomatch) => {
      console.log(nomatch);
    });

he doesnt go to the subscribe function, either nor to the match or nomatch

what is my problem ?

Assignat answered 14/6, 2018 at 7:57 Comment(0)
W
4

Please check this

    import {Component, ViewChild} from '@angular/core';
    import {Platform, Nav} from 'ionic-angular';
    import {StatusBar} from '@ionic-native/status-bar';
    import {SplashScreen} from '@ionic-native/splash-screen';
    import {Deeplinks} from '@ionic-native/deeplinks';

    @Component({
        templateUrl: 'app.html'
    })

    export class MyApp {
        rootPage: string = 'DashboardPage';
        @ViewChild(Nav) nav: Nav;

        constructor(public platform: Platform,
                    statusBar: StatusBar,
                    splashScreen: SplashScreen,
                    private deeplinks: Deeplinks) {

            platform.ready().then(() => {
                statusBar.styleDefault();
                splashScreen.hide();
                if (platform.is('cordova')) {
                        this.deeplinks.routeWithNavController(this.nav, {
                            '/event/:year/:month/:eventItem/:title': 'ScheduleDetails',
                            '/email/verify/': 'Login',
                            '/password/reset/:token': 'ChangePassword',
                            '/prd/:id': 'ProductDetailsPage',
                            '/rcm/:id': 'RecommendationDetailsPage'
                        }).subscribe((match) => {
                            // console.log('success' + JSON.stringify(match));
                        }, (noMatch) => {
                            // alert('error' + JSON.stringify(noMatch));
                            // console.log('error' + JSON.stringify(noMatch));
                        });
                }
            });
        }
    }

And don't forgot to add providers as Deeplinks in app.module.ts file

Winton answered 14/6, 2018 at 9:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.