簡體   English   中英

一次將模板通知發送到圖塊和烤面包

[英]Send template-notification to tile and toast once

我為WindowsPhone客戶端注冊了兩個不同的模板(一個用於tile更新,一個用於toast)。

是否可以只發送一個通知,而我的WindowsPhone客戶端卻獲得了敬酒通知和磁貼更新?

在msdn上找到一個帶有以下消息的論壇線程 (在答案中):

如果您像這樣調用方法SendTemplateNotificationAsync({“ templates的屬性”},“ en-us”)),則將定位該Toast並將兩個通知平鋪到設備A。

但這對我不起作用。 我的客戶僅收到圖塊更新,而不收到烤面包通知。

我還嘗試了同時在xml(平鋪和吐司)中使用的模板。 在這里找到 但這也行不通(只能在客戶端上看到吐司)。

我知道,我可以使用其他標簽(例如“ toast”和“ tile”),並像以下代碼段一樣發送通知。 但是我認為這是一個丑陋的解決方案:

await hubClient.SendTemplateNotificationAsync(content, tags + " && toast");
await hubClient.SendTemplateNotificationAsync(content, tags + " && tile");

任何幫助表示贊賞。 謝謝

編輯:我的模板和我的通知屬性:

特性:

var content = new Dictionary<string, string>
{
    {"title_en", "English title"},
    {"message_en", "English content"},
    {"title_de", "Deutscher Titel"},
    {"message_de", "Deutscher Inhalt"},
    {"url", url},
    {"count", count.ToString()}
};

吐司模板(WindowsPhone)

String.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
    "<wp:Notification xmlns:wp=\"WPNotification\">" +
    "<wp:Toast>" +
    "<wp:Text1>$(title_{0})</wp:Text1>" +
    "<wp:Text2>$(message_{0})</wp:Text2>" +
    "<wp:Param>$(url)</wp:Param>" +
    "</wp:Toast>" +
    "</wp:Notification>", language);

平鋪模板(WindowsPhone)

String.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
    "<wp:Notification xmlns:wp=\"WPNotification\">" +
    "<wp:Tile Template=\"IconicTile\">" +
    "<wp:SmallIconImage>Small.png</wp:SmallIconImage>" +
    "<wp:IconImage>Large.png</wp:IconImage>" +
    "<wp:WideContent1>$(title_{0})</wp:WideContent1>" +
    "<wp:WideContent2>$(message_{0})</wp:WideContent2>" +
    "<wp:WideContent3 Action=\"Clear\"></wp:WideContent3>" +
    "<wp:Count>$(count)</wp:Count>" +
    "<wp:Title>AppName</wp:Title>" +
    "</wp:Tile>" +
    "</wp:Notification>", language)
await hubClient.SendTemplateNotificationAsync(content, tags + " && toast");
await hubClient.SendTemplateNotificationAsync(content, tags + " && tile");

這不是一個丑陋的解決方案,實際上背后有一個原因。

template/registration always based on tags not based on payload keys. 所以實際上您已將模板注冊到=>等不同的標簽集

device A - toast template,  tags: {"en-us", "toast"}
device A - tile template , tags : {"en-us", "tile"}

在這種情況下,設備圖塊模板已使用以下tags : {"en-us", "tile"}注冊tags : {"en-us", "tile"}和Toast是tags: {"en-us", "toast"}並且這兩個注冊均不同,因此您無法發送他們在一個單一的請求。

IMO you can't have the both notification with this single call => SendTemplateNotificationAsync({“properties of template”}, “en-us”)) '因為IMO再次出現(因為我之前SendTemplateNotificationAsync({“properties of template”}, “en-us”))該問題)通知中心無法確定他必須發送到設備的模板(平鋪,吐司)。 因為它們每個都注冊有如上所述的不同標簽集。

也是為什么它不是一個丑陋的解決方案,因為它使您對通知有更多的控制權,因為您知道Toast和Tile通知具有不同的用途,但它們同時沒有提供任何額外的價值。

平鋪通知 =>它用於可能持續一段時間並且不會過時的信息。 像計數器,后退圖像,一些新更新等。此信息也不需要立即引起用戶的注意。

Toast Notification =>它用於發送非常即時的信息(希望您理解我的意思)。就像一些新消息一樣,您已經發布了新的更新等。

如果您始終同時發送兩個通知,那么在這種情況下,它實際上並沒有增加額外的價值。

暫無
暫無

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

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