Last active
December 24, 2015 01:24
-
-
Save wedgybo/7ee11834cc64b3f452f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ('cordova' in window) { | |
// Create a sticky event for handling the app being opened via a custom URL | |
cordova.addStickyDocumentEventHandler('handleopenurl'); | |
} | |
function handleOpenURL (url) { | |
cordova.fireDocumentEvent('handleopenurl', { url: url }); | |
}; |
What I ended up with are something like this
(function() {
var app = angular.module('mycoolapp', []);
app.run(['$window', function($window) {
// Subscribe to cold-start event
document.addEventListener('handleurl', handleOpen, false);
// re-register event handler
$window.handleOpenURL = function(url) {
handleOpen({
url: url
});
};
function handleOpen(e) {
handleExternalOpenURL(e.url);
}
});
})();
if ('cordova' in window) {
// Create a sticky event for handling the app being opened via a custom URL
cordova.addStickyDocumentEventHandler('handleurl');
}
function handleOpenURL (url) {
cordova.fireDocumentEvent('handleurl', { url: url });
}
Just saw this! Glad it helped out. There were a few typos previously that I think might have been causing some issues 😞
Hi,
I couldn't get it working on cold start on android. handleOpenURL(url) didn't get called. I was testing push notification that contains a deep link. Here is the flow:
- Receive push notification, click on it
- App is launched
- Landing page loaded. Didn't go to the page I specified in deep link.
I think it's because handleOpenURL() isn't there yet, when I click push notification?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks for this. I get the cold start to work but once the event is fired I cant fire it again. Any ideas?