Closed CookieCookson closed 9 years ago
Thanks for trying it out )
Can you post a link, that you are opening? Also, can you show more on how your JS file looks like? In general, it should be something like this:
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
bindEvents: function() {
document.addEventListener('handleUniversalLink', this.handleUniversalLink, false);
// your other code
},
// handleUniversalLink Event Handler
handleUniversalLink: function(event) {
console.log('Processing link');
},
// your other methods
};
app.initialize();
I'm following this link: https://artory.qualia.org.uk/link/instance/800/
Any URLs from that domain that are followed by /link/ get caught by the app. However, once in the App none of the event listeners fire off in Cordova. There are alot of JS files as it is quite an intricate app, however the event listener gets executed on run-time, and when switching out to follow a universal link it switches back to the app and then doesn't fire the event listener.
I've been doing NSLog traces through the code, and when it reaches handleUserActivity, host == nil becomes true... after digging deeper findHostByURL was failing when checking the schemes. After adding scheme="https" into the config.xml the event is now firing in javascript!
Great, that you found the problem! Missed that you are using https
:( Maybe should remove it from the url matching...
Easy mistake to make! Do you think the scheme matching is required?
Probably not. Matching is performed only to get a proper event name, that is send to JS. And developer is not gonna define two equal domains with different schemes (I hope).
From the native perspective scheme is used only for Android to inject correct settings in AndroidManifest.xml
. For iOS it is not used anywhere: only path and domain in the .entitlements
file.
So yes, I should remove scheme from the url matching.
Thanks for creating this plugin! I have got to the point of integration where the app is catching URLs and opening the App instead of a webpage, however once reaching the App the javascript event never fires so I cannot proceed any further.
My config.xml contains:
This should catch anything on the /link/ url and fire the "handleUniversalLink" event listener. In the JS I have:
It seems the event listener is never firing for handleUniversalLink and I have tried repeatedly using different variables such as the example vars etc and seem to have no luck.
Could it be because my URLs are being served from a sub-domain maybe? There are absolutely no errors in the JS or xCode console so no leads, and the plugin is definitely getting initialised on launch ([CDVTimer][universallinks] 1.968980ms).