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

Ionic4 ios not working #217

Open youngdolphin opened 4 years ago

youngdolphin commented 4 years ago

I have an iOS app that opens another app, ask a question and then this second app opens my app again with the url myapp://token/:token. It works and i think deeplink plugin is working, the console says:

To Native Cordova -> IonicDeeplinkPlugin onDeepLink IonicDeeplinkPlugin1673597617 ["options": []]

but the code inside the functions handling match and no match cases is never reached. My code: this.deeplinks.route({ '/token/:token': 'ExternalAuthPage' }).subscribe((match) => { console.log('match'); }, (nomatch) => { console.log('no match'); }); Is there a working ionic4 example? Thanks in advance for any help!

vadimwe commented 4 years ago

You need prefix in the path. This works for me: Link: 'myapp://app/test' private prepareDeeplinks() { return new Promise((resolve) => { this.deeplinks.route({ '/test' : TestPage }).subscribe(match => { // match.$route - the route we matched, which is the matched entry from the arguments to route() // match.$args - the args passed in the link // match.$link - the full link data this.loggedInRedirectPath = match.$link.path; resolve(); }, nomatch => { // nomatch.$link - the full link data // alert('no match - ' + JSON.stringify(nomatch)); resolve(); }); }); }

butterfly-valley commented 4 years ago

I have the same behaviour as the OP and have tried vadimwe's approach to no avail, could someone share their working setup please?

youngdolphin commented 4 years ago

@vadimwe can you share a better working example? I've tried your solutions with no success, the code inside the match (or nomatch) function is never reached.

butterfly-valley commented 4 years ago

Is there any update on this? I have checked the sysdiagnose file and all should be working however this.deeplinks.route is never reached on clicking on link, only the app is open. Thanks in advance.

butterfly-valley commented 4 years ago

It seems to be a capacitor issue since the CAPBridge.handleContinueActivity does not appear to connect to the deeplinks plugin. Can someone share their CAPBridge.handleContinueActivity implementation so that we can compare?

vadimwe commented 4 years ago

As I wrote. It works fine in iOS and Android (ionic 4, angular 8). The only modification you need is to modify incoming link:

myapp://test (Wrong in the documentation) myapp://someprefixhere/test (Right)

In my case, I use ionicapp://client-app/tasks/33 The plugin will convert it to localhost://tasks/33

Test on device or simulator only

butterfly-valley commented 4 years ago

As I wrote. It works fine in iOS and Android (ionic 4, angular 8). The only modification you need is to modify incoming link:

myapp://test (Wrong in the documentation) myapp://someprefixhere/test (Right)

In my case, I use ionicapp://client-app/tasks/33 The plugin will convert it to localhost://tasks/33

Test on device or simulator only

thanks, can you share your config, are you using Capacitor for your builds?

vadimwe commented 4 years ago

I use cordova.

Ionic:

Ionic CLI : 5.4.13 (/usr/local/lib/node_modules/ionic) Ionic Framework : @ionic/angular 4.11.7 @angular-devkit/build-angular : 0.803.20 @angular-devkit/schematics : 8.3.20 @angular/cli : 8.3.20 @ionic/angular-toolkit : 2.1.1

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1) Cordova Platforms : android 8.1.0, browser 5.0.4, ios 5.0.1 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 19 other plugins)

Utility:

cordova-res (update available: 0.8.1) : 0.3.0 native-run (update available: 0.3.0) : 0.2.9

System:

Android SDK Tools : 26.1.1 (/Users/vs/Library/Android/sdk) ios-deploy : 2.0.0 ios-sim : 8.0.2 NodeJS : v11.10.0 (/usr/local/bin/node) npm : 6.13.4 OS : macOS Mojave Xcode : Xcode 11.3 Build version 11C29

butterfly-valley commented 4 years ago

Thanks a lot, this does indeed seem like a Capacitor issue indeed.

butterfly-valley commented 4 years ago

The issue has proven to be Capacitor related. Whoever uses Capacitor just ditch any plugin whatsoever and use Capacitor's owner implementation for deep linking as described here: https://capacitor.ionicframework.com/docs/apis/app#method-addListener-1