ionic-team / ionic-plugin-deeplinks

Handle deeplinks into your Ionic/Cordova apps from Universal Links, App Links, and Custom URL schemes. For those using Ionic 2, there are some nice goodies that make life easier.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

match and no match never fire

mah-qurashy opened this issue · comments

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.

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

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

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

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

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.

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)

This seems to be fixed in f5f024e