Custom-URL-scheme
Custom-URL-scheme copied to clipboard
handleOpenURL
I am running this function when handleOpenURL when the user has already opened the app - I am using it to get a token from a url in an email. So the user installs the app and logins in, clicks the link and this function is called:
window.handleOpenURL = function (url) {
setTimeout(_ => {
console.log(url)
})
}
this runs fine and the user is logged in. The issue comes from once I close the app and open it again and try to do that process again. Login, click the email link and then nothing happens - the handleOpenURL function isn't called at all?
Does it work with [email protected]?
No, it doesn't
I guess i have the same issue. I open the app via custom url. If the App do a "cold start" then window.handleOpenUrl is not triggered. If the App already runs in Background, all is fine. I guess the registration of the window.handleOpenUrl is too late on a cold start, so the trigger is already gone...
I wasn't able to make it work. Unfortunately, my only solution was switching to a different plugin that supports deep links
It works with [email protected].
It works with [email protected].
Hi, I have [email protected], if the app is in the background if it works, but if the app is closed it doesn't work, even if you have [email protected], could you help me?
Hey @tmwebs , this extra cordova sticky event handler works for me to coldstart app ` if (window && 'cordova' in window) { // need this extra listener for app cold start ! window.cordova.addStickyDocumentEventHandler('handleurl'); window.handleOpenURL = url => window.cordova.fireDocumentEvent('handleurl', { url }); }
// somewhere on document / platform ready document.addEventListener('handleurl', (e: any) => isOpendFromUrl(e.url), false);
window.handleOpenURL = url => isOpendFromUrl(url)
function isOpendFromUrl(url) { console.log('isOpendFromUrl', url) }
`
Thanks!!!! I have managed to implement it in the following way: adding it in the index.html
<html>
<head>
</head>
<body>
<script src="cordova.js"></script>
</body>
<script>
function handleOpenURL(url) {
//do whatever you want
//it is safe to call any function with setTimeout
}
</script>
</html>
https://github.com/EddyVerbruggen/Custom-URL-scheme/issues/262#