Closed mklilley closed 5 years ago
Hi, Sorry for the late reply.
On what platform you are testing this: iOS, Android or both?
Haven't tried it like that (hashtag in the path), but my guess that the first configuration should be correct. Will test it and get back to you.
Hi, Not at all, thanks for getting back to me. I am using it on both iOS and Android, but I was first trying with Android and that's where I have had the problem.
Experimented with Android, since it's just simpler. As it turned out, you can't use query parameters as url pattern. Tried both #
and ?
in url pattern and both were ignored by Android.
When you define preferences in the config.xml
they are automatically transformed in the platform-specific configs. In the case of the Android:
<universal-links>
<host name="domain.com" scheme="https">
<path url="/#/*" />
</host>
</universal-links>
becomes in platforms/android/AndroidManifest.xml
:
...
<data android:host="domain.com"
android:pathPattern="/#/.*"
android:scheme="https" />
...
Android is using this pattern to match it to the url that user tries to open. And for that Android is using url without query and hash data: the pure uri. And since the defined pattern differs from the path - app is not opened.
Same thing happens if I set in AndroidManifest.xml
:
<data android:host="domain.com"
android:pathPattern="/.*?foo=bar"
android:scheme="https" />
And try to open https://domain.com/path?foo=bar
. It takes https://domain.com/path
and matches it to https://domain.com/.*?foo=bar
and don't get a match => app is not launched.
So you can't use query parameters for url matching. I'll add it to the docs...
Sad times :-(
I just found this http://stackoverflow.com/questions/16451162/intent-filter-pathprefix-with-not-working
I wonder whether we might try escaping it like this http://stackoverflow.com/questions/5007352/how-to-escape-hash-character-in-url
I'll try
:-(
Thanks for your quick help with this @nikDemyankov , much appreciated. In the end I decided to do a catch all /* and then do the checking for # inside the app. For those non hash routes I load an in app browser and for the hash routes I do my special stuff. Where there's a will there's a way :-D
Yes, seems like this is the only way to solve it... Great, that it worked out for you in the end :)
I am running into the same issue because I am using AngularJS, so all of my urls have '/#/'
I wanted to do this on my consumer app and they are not working:
<universal-links>
<host name="*.myConsumerApp.com" scheme="https">
<path url="/#/login/consumer" />
<path url="/#/consumerLogin" />
<path url="/#/registrationConsumer" />
<path url="/#/consumer/*" />
<path url="/#/verification?role=consumer" />
</host>
</universal-links>
When I click on test.myConsumerApp.com/#/login/consumer, not working...
I even tried:
<universal-links>
<host name="*.myConsumerApp.com" scheme="https">
<path url="*consumer*" />
</host>
</universal-links>
And the link is not working. Is it because Android automatically ignoring everything after '#" in url?
@brandon7810 :
Is it because Android automatically ignoring everything after '#" in url?
Yes, exactly. And nothing I can do with that. The only way is to capture all requests for myConsumerApp.com
and process actual url on a JS side.
config.xml:
<universal-links>
<host name="myConsumerApp.com" scheme="https" event="some_event_name"/>
</universal-links>
index.js:
universalLinks.subscribe('some_event_name', function (eventData) {
console.log('Did launch application from the link: ' + eventData.url);
});
Thanks for the quick reply! Okay. That's what I am doing but I have two apps having the same host 'myConsumerApp.com', and it was intended to be.
So it will alway show up my two apps in the option list if the users click on the links, but some links are not relevant to the second app or first app. We only want to show the option if the links are relevant. Do you have any solution/suggestion for this? Much appreciated!
The best would be: merge two apps into one since they are based on the same site and using the similar code. But, as I understand, that's not an option :(
Other approach is to redirect user from the wrong app to the correct one. For example, you can fork this repo, and add additional checking in here. If starting url is not supported by this app - launch intent, that will launch the correct one, or show error message, if second app is not installed. Or do the same thing on JS side, but via native it should work faster. Quite a bad UX, but at least user will be redirected to the correct app.
Other than that - has no idea, to be honest :(
Thanks @nikDemyankov I will try your workaround. I am not very good with Java and getting my own build, so I will try doing it on JS side. Do you have function that does the redirection to another app? I couldn't find it on the document. Otherwise I may try this https://github.com/lampaa/com.lampa.startapp
Glad to help :)
Do you have function that does the redirection to another app?
No, UL plugin doesn't have that kind of functionality since it doesn't need it. So, probably, yes - you should try to find special plugin for that...
đ Hi! Thank you for your interest in this repo.
đĸ We are not using nordnet/cordova-universal-links-plugin anymore, and we lack the manpower and the experience needed to maintain it. We are aware of the inconveniece that this may cause you. Feel free to use it as is, or create your own fork.
đ This will now be closed & locked.
âšī¸ Please see #160 for more information.
Hi,
I have links like https://domain.com/#/12345 that need to be loaded inside my app, but I also have links like https://domain.com/privacy.html that should not be loaded by the app. I tried to do something like this:
But it wouldnt work. I even tried this:
but also had no luck. Does universal links recognise the hash symbol?
Thanks,
Matt