I am developing WP8.1 app with WinJS. I am using push notifications. I want to execute a logic depending on "launch" string received in push notification payload. My toast notification payload is
<toast launch='launchString'>
<visual>
<binding template='ToastText02'>
<text id='1'>headlineText</text>
<text id='2'>bodyText</text>
</binding>
</visual>
</toast>
I have registered an event
WinJS.Application.addEventListener("activated", this.onActivated);
Which is defined as
onActivated: function (args) {
if (args.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
if (args.detail.arguments) {
var launchString = args.detail.arguments;
eval("angular.element(document.getElementById('mainBody')).scope().onNotification(launchString)")
}
else {
console.log("Not launched from toast notification")
}
}
}
Here onNotification(launchString) function has the logic which makes some decision making based on launchString.
Everything works fine when application is either in foreground or running in background. But when the application is in killed state, and I try to launch by tapping on toast notification, application crashes right after its launched. I am not able to debug this in VS as I could not recreate this scenario while debugging (because debugger exits when a debugging app is killed).
- Is there any way I can debug an app in killed state?
- What is the issue when I try to launch and read "launch" parameter when app is in killed state? How can I solve this?
Thanks for your help!
Edit: Here is a similar issue.
evalis evil. Never use it unless you absolutely must, and in that case you need to be extremely careful to be sure that there's no way for untrusted content to get into the execution line. If you were, for example, concatenating thelaunchStringvalue into yourevalparameter, you would be allowing arbitrary code execution in your app. Is there some reason you aren't just runningangular.element(document.getElementById('mainBody')).scope().onNotification(launchString)directly? - CBHackingonActivatedfunction is a plain javascipt file. This is the file where I am initializing and binding other stuff. MyonNotificationfunction is in an angular controller which uses other angular services to execute a logic. Hence I could not directly runangular.element(document.getElementById('mainBody')).scope().onNotification(launchString)as this is in plain javascript. - Sharvil