管理windows商店应用8.1中的toast通知
本文关键字:中的 toast 通知 应用 windows 管理 | 更新日期: 2023-09-27 18:18:22
在windows 8.1商店应用程序项目上,我希望能够接收吐司通知,然后在我的应用程序中管理它们的信息。
到目前为止,我有一个nodeJS服务器发送吐司通知和它的工作良好。
我想知道的是:首先,我如何处理接收通知的事件,其次,如果有一种方法可以在不同的页面打开应用程序,当我点击窗口上的toast通知时,取决于我得到的toast,例如,如果我得到一个toast说"Hello",我会点击它,应用程序会打开Hello。如果我有一个说"再见"的页面,我会打开页面中的应用程序Goodbye .xaml.
这是我在nodejs中发送的内容
wns.send({
channelURI: 'https://db5.notify.windows.com/?token=ABCD',
payload: '<toast launch="launch_arguments">'+
'<visual>'+
'<binding template="ToastText03">'+
'<text id="1">Notification - ' + date.toDateString().replace(/T/, ' ').replace(/'..+/, '')+ ' ' + date.getHours() + ':'+date.getMinutes() + '.</text>'+
'<text id="1">msg 123 test 456.</text>'+
'<text id="1">bla bla bla bla</text>'+
'</binding>'+
'</visual>'+
'</toast>',
type: 'toast'
});
这里有一个关于如何处理Toast通知的好话题:
http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/09/quickstart发送————当地土司- - -通知- - - -处理-激活-从- - windows - 10. - aspx
这里有一篇关于"互动祝酒通知"的好文章:http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/02/adaptive -和-互动-面包通知- windows - 10. - aspx
如果你想在windows 8.1上使用它,这里有一个很好的指导方针:
https://msdn.microsoft.com/en-us/library/windows/apps/hh761462.aspxhttps://msdn.microsoft.com/en-us/library/windows/apps/hh465391.aspx
UPDATE 1:
你可以使用launch参数发送你想要的所有数据,而不仅仅是参数。例如:看到"发射= . ."
wns.send({
channelURI: 'https://db5.notify.windows.com/?token=ABCD',
payload: '<toast launch="{'"params'":'"launch_arguments'",'"text'":'"Notification '",'"text_1'":'"msg 123 test 456'"}">'+
'<visual>'+
'<binding template="ToastText03">'+
'<text id="1">Notification - ' + date.toDateString().replace(/T/, ' ').replace(/'..+/, '')+ ' ' + date.getHours() + ':'+date.getMinutes() + '.</text>'+
'<text id="1">msg 123 test 456.</text>'+
'<text id="1">bla bla bla bla</text>'+
'</binding>'+
'</visual>'+
'</toast>',
type: 'toast'
});
你可以编辑:
"{'"params'":'"launch_arguments'",'"text'":'"Notification '",'"text_1'":'"msg 123 test 456'"}"
并且,你可以很容易地在App.cs中通过unjson来读取它…
裁判:https://msdn.microsoft.com/en-us/library/hh868212.aspx
更新2:你可以使用你自己的格式,而不是json ..我的意思是:param1:[val1],param2:[val2]…等等,你可以用一些正则表达式来反格式化:-)