Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 10 UWP + Cordova 7.1.0 - "activated" fired before plugin registered #327

Open
FBNitro opened this issue Aug 20, 2020 · 2 comments
Open

Comments

@FBNitro
Copy link
Contributor

FBNitro commented Aug 20, 2020

cordova.define("cordova-plugin-customurlscheme.LaunchMyApp", function(require, exports, module) {
(function () {
    function activatedHandler(e) {
        if (typeof handleOpenURL === "function" && e.uri) {
            handleOpenURL(e.uri.rawUri);
        }
    };

    document.addEventListener("activated", activatedHandler, false);
}());

});

I've traced through the UWP Cordova launch sequence, and I've found that in cordova.js, line 1392:
cordova.fireDocumentEvent('activated', platform.activationContext, true);
is fired before the customurlscheme plugin has registered.

So the call to handleOpenURL never occurs, because the event listener was added after the event has already fired.

@dharmendra-verma
Copy link

I am also experience same issue. @FBNitro any luck in resolving this?

@FBNitro
Copy link
Contributor Author

FBNitro commented Oct 11, 2020

In my index.js, before the 'deviceready' event, I added a listener for activated:

let activatedURI;
function activatedHandler(e) {
    if (e.uri) {
        activatedURI = e.uri.rawUri;
    }
}
document.addEventListener('activated', activatedHandler, false);

Then in the deviceready handler, before doing anything else, I removed the listener for activated, and dealt with the value if it was populated by calling window.handleOpenUrl(activatedUri); directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants