0

我爲WindowsPhone客戶端註冊了兩個不同的模板(一個用於tile-update和一個用於烤麪包)。發送模板通知到瓷磚和烤麪包一次

有沒有可能只發送一個通知,我的WindowsPhone客戶端得到敬酒通知和瓷磚更新?

我發現了一個forum thread on msdn與(在答題)以下消息:

如果你調用一個方法SendTemplateNotificationAsync({「 模板的屬性」},「EN-US」))這樣,那將目標吐司和瓦片 這兩個通知到設備答:

但這不會對我工作。我的客戶只獲取瓷磚更新而不是烤麪包通知。

我也嘗試過使用xml(平鋪和烤麪包)的模板。 Found here。但這也行不通(只在客戶端敬酒)。

我知道,我可以使用額外的標籤(如「吐司」和「瓷磚」),併發送通知,如下面的代碼片段。但我認爲這是一個醜陋的解決方案:

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) 
+0

其實它應該是可能的,就像它是在msdn論壇上所述。你能提供你的模板嗎?發送模板通知時,必須確保提供所有參數。 –

+0

我添加了通知的模板和屬性。謝謝 – Joehl

+0

您是否在每臺設備上使用兩個單獨的註冊,一個用於瓷磚,另一個用於烤麪包?您可以檢查通知中心的每臺設備是否真的有兩種不同的註冊? –

回答

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

這不是一個醜陋的解決方案,實際上存在着

template/registration always based on tags not based on payload keys.背後it.Selection一個原因所以實際上你已經註冊的模板組不同的像=>

device A - toast template, tags: {"en-us", "toast"} 
device A - tile template , 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(因爲我之前無法工作)通知中心無法決定他必須發送給設備的模板(平鋪,烤麪包)。因爲它們中的每一個都使用上述設置的不同標籤進行註冊。

此外,爲什麼它不是一個難看的解決方案,因爲它可以讓你更好地控制你的通知,因爲你知道吐司和瓦片通知有不同的目的,它們同時不提供任何額外的價值。

平鋪通知 =>它用於信息可以持續一段時間,並且不會更快陳舊。像計數器,背景圖片,一些新的更新等,這個信息並不需要立即用戶的注意。

Toast通知 =>它被用於發出信息那是相當的瞬間(希望你明白我的意思)。像一些新的消息傳來,您已經發布了一個新的更新等

如果您在這種情況下,一直髮送兩個通知,這實際上並沒有增加額外的價值。

+0

謝謝。這就是我想的......我想我需要用標籤來做。 – Joehl