镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.
This repository was archived by the owner on Aug 17, 2023. It is now read-only.

Deeplinks in ionic 4 not working #183

Open

Description

@Nikhil-Daffodil

I'm trying to using deep links in ionic 4 but unable to find success.

In app.component.ts
@ViewChild(IonNav) nav: IonNav;

    this.deeplinks.routeWithNavController(this.nav, {
        '/auth/password/reset/:authToken': 'ForgotPasswordPage'
    })
        .subscribe((match) => {
        }, (nomatch) => {
        });

In forgot-password.page.ts

this.authToken=this.route.snapshot.paramMap.get('authToken')

But when i click the link it opens the app but not the ForgotPassword Page and giving this error : Cannot read property 'push' of undefined

Activity

  1. hamid07ss commented on Mar 25, 2019

    @hamid07ss

    +1

  2. FURQAN2050 commented on Apr 7, 2019

    @FURQAN2050

    any update?

  3. hamid07ss commented on Apr 7, 2019

    @hamid07ss

    I installed a previous version of deeplinks and worked for me!
    my versions:

    "@angular/core": "5.2.10",
    "@ionic-native/core": "4.3.0",
    "@ionic-native/deeplinks": "^4.19.0",
    
  4. FURQAN2050 commented on Apr 7, 2019

    @FURQAN2050

    can your share example code here.or git repo of exmple implementation

  5. Nikhil-Daffodil commented on Apr 8, 2019

    @Nikhil-Daffodil
    Author

    I made a temporary solution for me like this:

    		this.deeplinks.route({
    			'/auth/password/reset/:authToken': ForgotPasswordPage
    		}).subscribe((match) => {
    			console.log('Successfully routed', match);
    			setTimeout(() => {
    				this.route.navigate(['/auth/password/reset/', match.$args.authToken])
    			}, 1000);
    		}, (nomatch) => {
    			console.warn('Unmatched Route', nomatch);
    		});
    

    on subscribe i made a route to desired page but i doubt it's working for multiple deeplinks page

  6. mwagena commented on May 6, 2019

    @mwagena

    +1 it's still an issue with the latest version... Code is similar as above.

  7. sambowenhughes commented on Jun 14, 2019

    @sambowenhughes

    Anything on this?!!

  8. mrambow commented on Jun 26, 2019

    @mrambow

    You have to run the navigation inside the angular zone.
    and don't forget to unsubscribe :)

    imports:
    import { NgZone } from '@angular/core';

    DI:
    private zone: NgZone,

    code:

    this.deeplinks.route({
                    '/auth/password/reset/:authToken': ForgotPasswordPage,
                })
                .subscribe((match) => {
                   this.zone.run(() => {
                        this.router.navigate([match.$link.path]); // path would be like /auth/password/reset/123xyz
                    });
                });
    
  9. added a commit that references this issue on Jul 9, 2019
    5138a4a
  10. cgbrucezjy commented on Sep 4, 2019

    @cgbrucezjy

    none of my path matches because my $link variable always have $link.path = "/"

  11. jordan-kaxig commented on Sep 27, 2019

    @jordan-kaxig

    none of my path matches because my $link variable always have $link.path = "/"

    Thats probably because the link refers to the second item between "/" and forward
    For example if you dump your "match" object, it can look like:

    {
        "$args":{},
        "$link":{
            "path":"/callback",
            "queryString":"",
            "fragment":"",
            "host":"app",
            "url":"testapp://app/callback",
            "scheme":"testapp"
        }
    }
    

    As you can se "path" represents the path from second item between "/" and forward, e.g "app" is not included in the "path" but is set as the property "host".
    So if you only have one item in your path, you probably find it in "host".

  12. SameeraRukshan commented on Feb 25, 2020

    @SameeraRukshan
    this.deeplinks.route({
                    '/auth/password/reset/:authToken': ForgotPasswordPage,
                })
                .subscribe((match) => {
                   this.zone.run(() => {
                        this.router.navigate([match.$link.path]); // path would be like /auth/password/reset/123xyz
                    });
                });
    

    For me had to put
    match.$link.host

  13. SergeyMell commented on Mar 21, 2020

    @SergeyMell

    None of the mentioned above solutions worked for me
    I've setup deep links handling according to capacitor documentation and it worked
    https://capacitor.ionicframework.com/docs/guides/deep-links/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions