Share via


ScheduledTileNotification.Id 屬性

定義

取得或設定用來識別排程中排程圖格的唯一識別碼。

public:
 property Platform::String ^ Id { Platform::String ^ get(); void set(Platform::String ^ value); };
winrt::hstring Id();

void Id(winrt::hstring value);
public string Id { get; set; }
var string = scheduledTileNotification.id;
scheduledTileNotification.id = string;
Public Property Id As String

屬性值

String

Platform::String

winrt::hstring

通知的識別碼。 此字串限制為 16 個字元。

範例

下列範例顯示排程在一小時內顯示的圖格,包括使用 Id 屬性來標記排程的通知。

var Notifications = Windows.UI.Notifications;
var currentTime = new Date();
var seconds = 60;
var dueTime = new Date(currentTime.getTime() + seconds * 60 * 1000);
var idNumber = 123456789;

var tileXml = Notifications.TileUpdateManager.getTemplateContent(Notifications.TileTemplateType.tileWide310x150Text09);

// Set up the wide tile text.
var tileTextAttributes = tileXml.getElementsByTagName("text");
tileTextAttributes[0].appendChild(tileXml.createTextNode("This is a scheduled notification"));
tileTextAttributes[1].appendChild(tileXml.createTextNode("Received: " + dueTime.toLocaleTimeString()));

// Set up the medium tile text.
var squareTileXml = Notifications.TileUpdateManager.getTemplateContent(Notifications.TileTemplateType.tileSquare150x150Text04);
var squareTileTextAttributes = squareTileXml.getElementsByTagName("text");
squareTileTextAttributes[0].appendChild(squareTileXml.createTextNode("This is a scheduled notification"));

// Include the medium tile in the notification.
var node = tileXml.importNode(squareTileXml.getElementsByTagName("binding").item(0), true);
tileXml.getElementsByTagName("visual").item(0).appendChild(node);

// Create the notification object.
var futureTile = new Notifications.ScheduledTileNotification(tileXml, dueTime);
futureTile.id = "Tile" + idNumber;

// Add to the schedule.
Notifications.TileUpdateManager.createTileUpdaterForApplication().addToSchedule(futureTile);

備註

ScheduledTileNotification.tag 和 ScheduledTileNotification.id 提供類似用途:

  • Windows 會使用 ScheduledTileNotification.tag 屬性來防止重複的通知內容同時出現在佇列中。 它可讓通知在佇列中就地更新,以防止它包含過期的資訊。
  • id 屬性會識別排程中的通知。 這可讓通知從排程中識別或移除。

適用於