通过单击toasts with params (WinJS)导航到特定的html页面

Navigate to a specific html page on clicking toasts with params (WinJS)

本文关键字:导航 页面 html WinJS 单击 toasts with params      更新时间:2023-09-26

我有一个WinJS项目,我从我的webservice收到toast通知。在我的webservice中,XML是这样的:

 string type = "Computer";
            string toast1 = "<?xml version='"1.0'" encoding='"utf-8'"?> ";
            string message = "{'"Message'":{'"Id'":'"6724d22a-87fe-4137-b501-9d9a9a0558b1'",'"DetailId'":'"dc02e784-7832-4625-a538-29be7f885ccb'",'"Description'":'" Message'",'"UserName'":null,'"ActionDateTime'":'"2015-09-15T15:36:14+05:45'",'"CalamityId'":'"c0fa848e-ee6c-4b91-8391-a12058f25387'",'"UseConferenceCalls'":true,'"IsActionCompleted'":false},'"Type'":'"COmp'"}";
          string toast2 = string.Format(@"<toast launch= '{0}'>
                     <visual version='1'>
                         <binding template='ToastText04'>
                             <text id='1'>{1}</text>
                               <text id='2'>{2}</text>
                         </binding>
                     </visual>
                 </toast>", message, "Alert", type);
           string xml = toast1 + toast2;

我想导航到一个特定的html页面与有用的json作为参数,当用户点击祝酒词。请给我一些建议。

目前,我已经实现了以下函数来处理我的toast。这只适用于应用程序处于活动状态,即在前台或后台运行。但是当应用程序完全关闭后,这个功能就不起作用了,无法满足我的要求。

WinJS.Application.addEventListener("activated", onActivatedHandler, true);
function onActivatedHandler(args) {
    if (args.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
        var messageDetails = (args.detail.arguments).replace(/''/g, '');
        PhonegapService.setNotificationMessage(messageDetails, function () {
            window.location.href = "page3.html";
        });
    }
}

我也面临着类似的问题。在我的情况下,我调用函数甚至在cordova deviceready被解雇之前。从你的问题不确定如果你是一个cordova应用程序或不是,但要确保所有所需的javascript文件加载。一旦文档准备好,就可以执行逻辑。我假设你正在使用jquery。

function onActivatedHandler(args) {
if (args.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
    $(document).ready(function(){
    var messageDetails = (args.detail.arguments).replace(/''/g, '');
    PhonegapService.setNotificationMessage(messageDetails, function () {
        window.location.href = "page3.html";
    });
});
}

}