簡體   English   中英

在Windows Store App 8.1中管理吐司通知

[英]Managing toast notifications in windows store app 8.1

在Windows 8.1商店應用程序項目上,我希望能夠接收烤面包通知,然后在我的應用程序中管理它們的信息。

到目前為止,我有一個nodeJS服務器,可以發送吐司通知並正常運行。

我想知道的是:首先,我如何處理接收通知的事件,其次,如果我有一種方法可以在不同的頁面中打開應用程序,當我單擊Windows上的Toast通知時,具體取決於我的Toast。例如,如果我舉杯說“你好”,我會單擊它,並且該應用程序將在hello.xaml頁面上打開,如果我說“再見”,則將在頁面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 Notification的好話題:

http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/09/quickstart-sending-a-local-toast-notification-and-handling-activations-from-it-windows-10.aspx

這是一篇關於“交互式吐司通知”的非常好的文章: http : //blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/02/adaptive-and-interactive-toast-notifications-for-windows- 10.aspx

如果您想在Windows 8.1上使用它,請遵循以下指導原則:

https://msdn.microsoft.com/zh-CN/library/windows/apps/hh761462.aspx https://msdn.microsoft.com/en-us/library/windows/apps/hh465391.aspx

更新1:

您可以使用啟動參數來發送所需的所有數據,而不僅是params ..即:請參見“ 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\"}"

而且,您可以通過取消json的方式在App.cs中輕松閱讀該內容...

參考: https : //msdn.microsoft.com/zh-cn/library/hh868212.aspx

更新2:

您可以使用自己的格式,而不是json ..我的意思是:param1:[val1],param2:[val2] ..等等,您可以做一些正則表達式來取消格式化:-)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM