Ionic-plugin-deeplinks unsubscribe when path unmatched

Hello

I have been using ionic-plugin-deeplinks and I have seen the following behavior:

When an unmatched route is triggered, then the plugin stops triggering the subscribed functions on matched routes that may trigger next.

for example:

    this.eventSubscription=this.deeplinks.route(this.routes)
      .subscribe(
        (match)=>{ this.onDeepLinkMatch(match) },
        (nomatch)=>{ this.onDeepLinkNoMatch(nomatch) }
      );

If the onDeepLinkNoMatch() called once, then both of my onDeepLinkā€¦ functions do not trigger.
The deeplink is captured because I can see in the console:

On deep link 
Object {url: ...

The only way to bypass this, is to re-subscribe when the onDeepLinkNoMatch() is called.

But then, Iā€™m starting seeing two console.log entries of ā€˜On deep linkā€¦ā€™ messages.
If another unmatched deeplink occurs, and I subscribe again, then I see 3 ā€˜On deep linkā€¦ā€™ messages in console.log. And so on.

Using

this.eventSubscription.unsubscribe();

before subscribing anew, does not help.

Is the team aware of this behavior?
Or am I doing something wrong?

Thank you
Costas

Hello killerchip!

I stunned with the same issue, did you find how to fix it?

Thank you for help!

Agree with @killerchip, I faced that this week too, I think itā€™s an issue (on my comment at the bottom I tried to link the possible duplicated issues):

As you, the only workaround I found so fat was subscribing again when there is a nomatch

Eventually, I dropped using the ionicā€™s deeplinks, and started using

Itā€™s free for the ā€œQuick linksā€ aka deeplinks, and also provide support for redirecting to AppStore, Google Play, when the app is not installed.

1 Like

Please , can you provide a code example on how you implemented in your ionic 3 project .
Thanks

Hello

If you are referring to my post, hereā€™s branchā€™s doc for Cordova, ionic projects:

https://docs.branch.io/pages/apps/cordova-phonegap-ionic/

@killerchip it was maybe a clever move, ionic-plugin-deeplinks has been now marked as ā€œNO LONGER MAINTAINEDā€ with branch.io as recommended solution

And this is why people go native, because of bad support like this, 2 years old and still the same issue. The module is poorly coded. The problem is @ionic-native/deeplinks. Observable should NOT be used here.

There is a workaround on this post

and a possible future better workaround to come.

Workaround:


var dl = window['IonicDeeplink'];

dl.route(
	{
		'/about-us': HomePage,
		'/something/:somethingId' : HomePage,
	},
	(match) => {
		console.log(' === 2 Deeplink: success. ', match);
	},
	(nomatch) => {
		console.error(' === 2 Deeplink nomatch: ', nomatch);
	}
);
1 Like