Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

match and no match never fire #245

Open
mah-qurashy opened this issue Apr 1, 2021 · 7 comments
Open

match and no match never fire #245

mah-qurashy opened this issue Apr 1, 2021 · 7 comments

Comments

@mah-qurashy
Copy link

I'm trying to use this plugin to setup deep links on my android app, here's my code, in app.component.ts

ngAfterViewInit() {
  this.platform.ready().then(() => {
    this.deeplinks
        .route({
          '/secondaryLogin/:id': 'secondaryLogin',
          '/userinfo/:id': 'userinfo',
        })
        .subscribe((match) => {
          this.toastr.success('deeplink matched' + JSON.stringify(match));
          const internalPath = `/${match.$route}/${match.$args['id']}`;
          // Run the navigation in the Angular zone
          this.zone.run(
            () => {
                this.router.navigateByUrl(internalPath);
            },
            (nomatch) => {
              // nomatch.$link - the full link data
              this.toastr.error(
                "Got a deeplink that didn't match" + JSON.stringify(nomatch)
              );
            }
          );
        });
  });
}

On clicking a link, the match and no match functions are never called, I'm not getting any toasters, the app opens to the home page and does not navigate.

@joe-at-startupmedia
Copy link

It seems because there is no .subscribe method chained to .route. Instead it takes three arguments where the last two arguments should be those of the .route method. Most likely a duplicate of #148

@kaililleby
Copy link

To me it seems that the following commit bdd2d91 introduces an error in deeplink.js.
The change from self.routeMatch(targetPath, realPath) to self.routeMatch(pathData, realPath) makes no sense - pathData is an object and will make the call to self.routeMatch(..) to throw an exception

@kaililleby
Copy link

@elylucas perhaps you could verify that the change in bdd2d91 is the cause of this problem?

@mah-qurashy
Copy link
Author

It seems because there is no .subscribe method chained to .route. Instead it takes three arguments where the last two arguments should be those of the .route method. Most likely a duplicate of #148

tested with passing match and nomatch functions directly to .route, still having same issue, they do not fire

@mah-qurashy
Copy link
Author

To me it seems that the following commit bdd2d91 introduces an error in deeplink.js. The change from self.routeMatch(targetPath, realPath) to self.routeMatch(pathData, realPath) makes no sense - pathData is an object and will make the call to self.routeMatch(..) to throw an exception

My issue was fixed by manually switching pathData to targetPath in the plugin, thank you.

@jderose9
Copy link

jderose9 commented Dec 8, 2021

This seemed like it was working for a while for me, but lately the nomatch handler was firing inconsistently. Seems like it would stop firing after the first use. I used the instance of the object on the window rather than the angular wrapper as detailed here:

#148 (comment)

@kaililleby
Copy link

This seems to be fixed in f5f024e

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants