Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling toast notification in Windows Phone 8.1 when app is closed

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.

like image 627
Kishor Bikram Oli Avatar asked Aug 07 '15 11:08

Kishor Bikram Oli


1 Answers

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.

  1. Try using pushnotificationreceived event, it will give you whole toast notification xml string and you can further work on it.

  2. 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.

like image 101
DOTNET Team - WeblineIndia Avatar answered Oct 06 '22 04:10

DOTNET Team - WeblineIndia