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.
Other
333 stars 217 forks source link

click callbacks not always fired on IOS and ionic3 #232

Open AleCat83 opened 3 years ago

AleCat83 commented 3 years ago

Hello,

I m using the plugin along with Ionic 3 and @ionic-native/deeplinks. I listen for deep link clicks using the method route. In most of the cases it works fine but sometimes the callback are not called. When this happen I can see in the logs the string "No Match found" or "Match found /XXXXX" but the callbacks (both next or error) that I set using subscribe are not called. Digging a bit more I discovered that the log messages comes from the "www/deeplinks.js" file, so the js bridge receive the callbacks from the native layer but it is not passed to the subscribe callbacks.

ShadananaK commented 3 years ago

Hi,

Even I am facing exactly same issue when it comes to IOS app using ionic 3. Some time it works fine and some time get "No Match found" string as log randomly. Is there any solution or work around to this problem ? Please help.

Regards, Shadanana

uxFeranmi commented 3 years ago

@AleCat83, @ShadananaK, this issue has also been reported here: #77. I found a workaround in that thread and there's also more explanation on why it happens.

uxFeranmi commented 3 years ago

This seems to work fine, using the plugin through the window object instead of the ionic-native wrapper. Better than re-subscribing to the observable after each nomatch occurence because the plugin's path matching function is called multiple times for each time you re-subscribe.

        window['IonicDeeplink'].route(this.Globals.Deeplinks,
            (match) => {
                console.log('Deeplink path found!');
                console.log(`Deeplink path found: ${JSON.stringify(match)}`);

                navigate(match);
            }, (nomatch) => {
                console.log('Deeplink path NOT found!');
                console.log(`Deeplink path NOT found: ${JSON.stringify(nomatch)}`);

                navigate(nomatch);
            }
        );
AleCat83 commented 3 years ago

This seems to work fine, using the plugin through the window object instead of the ionic-native wrapper. Better than re-subscribing cute to the observable after each nomatch occurence because the plugin's path matching function is called multiple times for each time you re-subscribe.

        window['IonicDeeplink'].route(this.Globals.Deeplinks,
            (match) => {
                console.log('Deeplink path found!');
                console.log(`Deeplink path found: ${JSON.stringify(match)}`);

                navigate(match);
            }, (nomatch) => {
                console.log('Deeplink path NOT found!');
                console.log(`Deeplink path NOT found: ${JSON.stringify(nomatch)}`);

                navigate(nomatch);
            }
        );

Thanks, this workaround works for me, and I agree that it's better than recreate the observable on error as it may lead to memory leaks.

jpike88 commented 3 years ago

observable method also isn't reliable (seems to only fire nomatch the first time, then subsequent tries fails)