[
https://issues.apache.org/jira/browse/CB-11924?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15582338#comment-15582338
]
Sergey Shakhnazarov commented on CB-11924:
------------------------------------------
[~sebastienlorber], thanks for reporting!
I've tested this and the following approach works for me:
{code}
var app = {
...
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
document.addEventListener('activated', this.onActivated, false);
},
onActivated: function (args) {
console.log('onActivated');
app.activated = true;
app.activatedArgs = args;
// Sometimes onActivated fires before deviceready, so plugins might not
be ready
navigator && navigator.notification && navigator.notification.alert &&
navigator.notification.alert('onActivated: ' + JSON.stringify(args));
// ^ this happens on Windows Anniversary
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
if (app.activated) {
// Sometimes onActivated fires before deviceready, so plugins might
not be ready
navigator && navigator.notification && navigator.notification.alert
&& navigator.notification.alert('onDeviceReady, onActivated (from the past): '
+ JSON.stringify(app.activatedArgs));
}
},
...
{code}
I.e. we are able to receive shared uri in {{activated}} event handler - it just
might fire before deviceready so activation args should be stored in the app
context - I've send a PR for the docs update.
> Share target: sharing to cordova app makes the app open but crashes afterwards
> ------------------------------------------------------------------------------
>
> Key: CB-11924
> URL: https://issues.apache.org/jira/browse/CB-11924
> Project: Apache Cordova
> Issue Type: Bug
> Components: Windows
> Affects Versions: 4.4.2
> Environment: Windows 10, cordova cli 6.1.1, affects cordova platform
> 4.4.2, also current 4.5.0 dev branch.
> Reporter: Sebastien Lorber
>
> Steps to reproduce:
> ========================
> {code}
> cordova create shareTargetTest
> cd shareTargetTest
> cordova platform add https://github.com/apache/cordova-windows
> {code}
> In manifest, add Share Target of type URI, leading to the following XML:
> {code}
> <Extensions>
> <uap:Extension Category="windows.shareTarget">
> <uap:ShareTarget>
> <uap:DataFormat>URI</uap:DataFormat>
> </uap:ShareTarget>
> </uap:Extension>
> </Extensions>
> {code}
> Run Windows 10 emulator (also crashed on HP Elite X3 device)
> Open Edge browser on any page, and share page to HelloCordova app.
> The HelloCordova app opens, and after some seconds, the emulator crashes
> (WWAHost.exe fails with code = -1: don't know how to get more details
> unfortunatly)
> --------------------------------------------------------------------------
> Expected result:
> ========================
> I don't know if this has ever been done by anyone on a Cordova app, but I
> want to share a Edge link to my application. For Android/iOS, this means that
> the app should open, or resume itself, and call some JS callback.
> I tried to follow these Windows8 tutorials that still look relevant for
> Windows10 app, with no success.
> https://msdn.microsoft.com/en-us/library/windows/apps/hh758301.aspx
> It seems the "activated" callback never fires (weither it's declared in my
> app, or in cordova.js, at least I don't see anything in the console logs I've
> put everywhere).
> Can you tell me if I do anything wrong to achieve this usecase? thanks
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]