Closed mklilley closed 5 years ago
Hi, Thanks :)
Tried to reproduce your issue and failed... This is what I did:
Created new project:
> cordova create ul
> cd ul
> cordova platform add android
> cordova plugin add cordova-universal-links-plugin
Added your configuration into config.xml
:
<universal-links>
<host name="*.myapp.com" scheme="https">
<path url="*verify*" event="verify"/>
<path url="/*" event="load"/>
</host>
</universal-links>
Added listeners to JS code (index.js
):
onDeviceReady: function() {
app.receivedEvent('deviceready');
universalLinks.subscribe('verify', function(data) {
alert('verify: ' + JSON.stringify(data, null, 2));
});
universalLinks.subscribe('load', function(data) {
alert('load: ' + JSON.stringify(data, null, 2));
});
},
Launched the app:
> cordova run android
Then from the console I simulated launch from the link:
> db shell am start -W -a android.intent.action.VIEW -d "https://test.myapp.com/_verify_/" io.cordova.hellocordova
> adb shell am start -W -a android.intent.action.VIEW -d "https://test.myapp.com/_some_/" io.cordova.hellocordova
As a result - event was triggered. I've tried it one after another, with app been closed via back button and home button. Worked in each case...
Maybe I missed something in the steps above?
Hi Nik,
Thanks for your thorough response. I'll have a go at that in the morning when my brain is all fresh :-)
One thing that I do notice is that you testing with test.myapp.com. I should have been more explicit in my initial post, but the strange behaviour I am observing is for myapp.com links.
Just to clarify my intentions in all of this - I wanted to use wildcard so that I could use myapp.com links and also use links like test.myapp.com, but when I observed the problem in the original links of the form myapp.com I thought I should seek clarification.
Thanks again,
Matt
ps I did wonder whether I needed to have a separate line for myapp.com and *.myapp.com in my config file to cover all cases but I wasn't sure. I was also confused when reading android docs online and some stack overflow posts that suggest you can't use wildcards https://developer.android.com/training/app-links/index.html#request-verify http://stackoverflow.com/questions/34068467/multiple-subdomain-support-with-app-links
Although I can't find right now android docs regarding wildcard in domain, it feels like this works. Otherwise adb
command would not launch it.
But if you were testing it like test.myapp.com
and myapp.com
, and used *.myapp.com
- probably it's not gonna work for the myapp.com
.
If you know exactly what subdomains you will use - I would suggest you to define them explicitly. If not - then define one set of preferences for myapp.com
and another one for *.myapp.com
:
<universal-links>
<host name="*.myapp.com" scheme="https">
<path url="*verify*" event="verify"/>
<path url="/*" event="load"/>
</host>
<host name="myapp.com" scheme="https">
<path url="*verify*" event="verify"/>
<path url="/*" event="load"/>
</host>
</universal-links>
Thanks Nik,
From what I have been reading it seems like the wildcard will work to load the app - but if you want to take advantage of Androids assetlinks (which allow the link to load your app without asking you which app you want to launch) I think that might not work with wildcard (although I cant check this as I don't have a high enough version of Android on my phone :-( )
Thanks again
Matt
ps it could be worth adding to the docs that if you want domain and all subdomains then you should add an extra bit to the config.
Yes, you are probably right... I'll update the docs.
👋 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,
Loving this plugin, thanks again for making it.
Up until now I have had the following in my config.xml file
All has been fine. I actually didn't realise I needed to have a file on my server for Android to be able to verify things, but still everything has been fine without it - I tap a link, Android asks which app to use, I choose my app and it loads and the events fire.
Now, I changed my config file to have a wildcard domain like this:
Now the behaviour is different. I tap on a link and chrome briefly pops up then android asks me what app I want to use, then i select my app which then loads....but the events don't fire anymore.
Have you ever seen this behaviour? Im using Nexus 4 with Android version 5.1.1
Thanks,
Matt