I'm handling Toast Notifications on Windows Phone 8.1 app (using HTML/JS,CSS) when user click on notifications(On action bar) with the following code snippet: Reference: https://msdn.microsoft.com/en-us/library/windows/apps/hh761468.aspx
WinJS.Application.addEventListener("activated", onActivatedHandler, false);
function onActivatedHandler(args) {
if (args.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
localStorage.messageDetails = args.detail.arguments;
window.location.href = "index.html";
}
}
It works well when the app is running in foreground or background. But, when I click on notifications, it is not hitting the above code snippet when the app is not running (foreground or background). I don't know what I'm doing wrong. Please help me on this. Thanks in advance.
I do not know technical reason why it is not working as you have implemented it right way. But there are two points I want you to check and I hope your issue will be solved.
Try using pushnotificationreceived event, it will give you whole toast notification xml string and you can further work on it.
It is possible that the page is not able to load the whole html and javascript when a launch is triggered. So you can use Window.SetTimeout for 1 second or more seconds delay inside the If condition of activated event handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With