Carles Ferreiro
Carles Ferreiro

Reputation: 64

Ionic universal links to subfolder

I've implemented universal links in my ionic app in order to open the app instead of my website. The problem is that now it is opening all urls in my domain (i.e. https://www.mydomain.mx/xxxxx). Instead of this I want to open only urls from a subfolder i.e. https://www.mydomain.mx/applink/open/xxxxx.

Examples of the problem:

https://www.mydomain.mx/ is opened and it should not
https://www.mydomain.mx/products is opened and it should not
https://www.mydomain.mx/applink/open/ is opened and it is ok

When I installed the universalinks ionic plugin I used this configuration (I have two domains and the behaviour is the same for both):

cordova plugin add ionic-plugin-deeplinks 
--variable URL_SCHEME=myurlscheme 
--variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=www.mydomain.org --variable ANDROID_PATH_PREFIX=/applink/open/
--variable DEEPLINK_2_SCHEME=https --variable DEEPLINK_2_HOST=www.mydomain.mx --variable ANDROID_2_PATH_PREFIX=/applink/open/

I tried to remove and add Android platform several times.

Thanks for your help!

Upvotes: 0

Views: 133

Answers (1)

Carles Ferreiro
Carles Ferreiro

Reputation: 64

Well, after some tests i found that it's due to ionic-plugin-deeplinks, that is creating empty intent filter data in AndroidManifest.xml.

One approach is to add some random hosts when installing the plugin:

cordova plugin add ionic-plugin-deeplinks --variable URL_SCHEME=myscheme 
--variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=www.mydomain.org --variable ANDROID_PATH_PREFIX=/applink/open/ 
--variable DEEPLINK_2_SCHEME=https --variable DEEPLINK_2_HOST=www.mydomain.mx --variable ANDROID_2_PATH_PREFIX=/applink/open/ 
--variable DEEPLINK_3_SCHEME=https --variable DEEPLINK_3_HOST=www.random1.com --variable ANDROID_3_PATH_PREFIX=/applink/open/ 
--variable DEEPLINK_4_SCHEME=https --variable DEEPLINK_4_HOST=www.random2.com --variable ANDROID_4_PATH_PREFIX=/applink/open/ 
--variable DEEPLINK_5_SCHEME=https --variable DEEPLINK_5_HOST=www.random3.com --variable ANDROID_5_PATH_PREFIX=/applink/open/

Other solution that seems work for some people is to add the configuration directly in config.xml (see https://github.com/ionic-team/ionic-plugin-deeplinks/issues/165), wich for me results in compilation errors.

Upvotes: 0

Related Questions