I need to implement deeplinks in my app so that I can browse to an specific page of my app, passing parameters, through a link received by email?
The oficial documentation is very limited and don’t show examples.
I found this post. Following it I was able to open my app using a adb command, but it don’t navigates to an specific page.
Another problem is related to import.
I was not able to use the import specified in the documentation:
import { IonicDeeplinks } from 'ionic-native';
Instead I was able to use:
import { Deeplinks } from 'ionic-native';
I installed th plugin this way:
ionic plugin add ionic-plugin-deeplinks --variable URL_SCHEME=“anrandomname://” --variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=“somewebsite.com.br”`
My app.ts:
import {StatusBar, File, Deeplinks} from ‘ionic-native’;
ngAfterViewInit() {
this.platform.ready().then(() => {
Deeplinks.routeWithNavController(this.nav, {
'/documents': DocumentsPage,
'/messages': MessagesPage
}).subscribe((match) => {
console.log('Successfully routed', match);
}, (nomatch) => {
console.warn('Unmatched Route', nomatch);
});;
});
}
Simulating the deeplink:
adb shell am start -a android.intent.action.VIEW -e “anrandomname://app/messages” br.com.somewebsite.myapp
Then I get this:
My app is not present.
The terminal shows:
Starting: Intent { act=android.intent.action.VIEW (has extras) }
I think the URL_SCHEME just requires the name.
So URL_SCHEME=“anrandomname://” becomes URL_SCHEME=“anrandomname”
1 Like