2013-12-23 47 views
1

我有一個應用程序框架(使用JavaScript),它動態設置實時切片源的URL。在我的代碼中,我有類似於下面的內容,這適用於寬廣的圖塊,但是當我將圖塊大小調整爲「中等」(或「小」)時,實時Feed /更新消失。如果我調整大小,它就可以工作。沒有其他瓷磚設置(它使用默認設置)。定期通知更新WIndows 8應用程序中的所有切片大小

我的問題是:反正是有在同一時間更新所有瓷磚的大小,否則我將不得不建立使用getTemplateContent()和一個完整的XML對象TileUpdater的update()方法?

我現在更新,像這樣的週期性的URL(同樣,這適用於寬瓦):

var updater = Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication(); 
updater.clear(); 
updater.stopPeriodicUpdate(); 
updater.enableNotificationQueue(true); 
updater.startPeriodicUpdateBatch(
    [ new Windows.Foundation.Uri(feedUrlString) ], 
    Windows.UI.Notifications.PeriodicUpdateRecurrence.halfHour 
); 

回答

1

要在單個更新更新多個瓷磚尺寸,該更新的XML有效載荷必須包含單個元素每個瓷磚大小。

您可以在SDK中的App tiles and badges sample中看到這一點。例如,場景1演示瞭如何使用(a)C#NotificationExtensions庫,(b)將XML構建爲字符串,以及(c)使用getTemplateContent。其中一種方法應該適合你。

舉的情況的一個例子(一),這裏是從方案1中的代碼,也有一個註釋說明更多:

// This sample application supports all four tile sizes – small (Square70x70), medium (Square150x150), wide (Wide310x150) and large (Square310x310). 
// This means that the user may have resized their tile to any of these four sizes for their custom Start screen layout. 
// Because an app has no way of knowing what size the user resized their app tile to, an app should include template bindings 
// for each supported tile sizes in their notifications. The only exception is the small (Square70x70) tile size because this size 
// does not support live tile notifications, which is why there are no Square70x70 tile templates. 
// We assemble one notification with three template bindings by including the content for each smaller 
// tile in the next size up. Square310x310 includes Wide310x150, which includes Square150x150. 
// If we leave off the content for a tile size which the application supports, the user will not see the 
// notification if the tile is set to that size. 

// Create a notification for the Square310x310 tile using one of the available templates for the size. 
var tileContent = NotificationsExtensions.TileContent.TileContentFactory.createTileSquare310x310Text09(); 
tileContent.textHeadingWrap.text = "Hello World! My very own tile notification"; 

// Create a notification for the Wide310x150 tile using one of the available templates for the size. 
var wide310x150Content = NotificationsExtensions.TileContent.TileContentFactory.createTileWide310x150Text03(); 
wide310x150Content.textHeadingWrap.text = "Hello World! My very own tile notification"; 

// Create a notification for the Square150x150 tile using one of the available templates for the size. 
var square150x150Content = NotificationsExtensions.TileContent.TileContentFactory.createTileSquare150x150Text04(); 
square150x150Content.textBodyWrap.text = "Hello World! My very own tile notification"; 

// Attach the Square150x150 template to the Wide310x150 template. 
wide310x150Content.square150x150Content = square150x150Content; 

// Attach the Wide310x150 template to the Square310x310 template. 
tileContent.wide310x150Content = wide310x150Content; 

// Send the notification to the application’s tile. 
Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileContent.createNotification()); 
+0

有趣的...我從來沒有想過到其他模板的內容附加到逐漸增大的圖塊內容對象。這看起來很奇怪。我會試一試,謝謝你的回答! – jakerella

+0

是的,我同意它有點反直覺,但它是要走的路:) –

+1

不幸的是,這是行不通的。這是一種將通知推送到現有圖塊的方法,但不會更新圖塊上的定期通知。我在問題中的代碼確實如此,但只能在寬廣的區塊中使用。我仍然無法更新所有大小的定期通知。 – jakerella

相關問題