AppNotificationBuilder.SetTag(String) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置应用通知的标记标识符。
public:
virtual AppNotificationBuilder ^ SetTag(Platform::String ^ value) = SetTag;
AppNotificationBuilder SetTag(winrt::hstring const& value);
public AppNotificationBuilder SetTag(string value);
function setTag(value)
Public Function SetTag (value As String) As AppNotificationBuilder
参数
- value
-
String
Platform::String
winrt::hstring
一个字符串,标识与应用通知关联的标记。
返回
返回 AppNotificationBuilder 实例,以便可以链接其他方法调用。
示例
以下示例演示如何设置应用通知的 标记。
var notification = new AppNotificationBuilder()
.AddText("Notification text.")
.SetTag("Tag value")
.BuildNotification();
AppNotificationManager.Default.Show(notification);
生成的 XML 有效负载:
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Notification text.</text>
</binding>
</visual>
</toast>
通过标记从通知中心删除所有通知的示例。
await AppNotificationManager.Default.RemoveByTagAsync("Tag value");
注解
可以使用 标记通过调用 AppNotificationManager.RemoveByTagAsync 或 AppNotificationManager.RemoveByTagAndGroupAsync 从通知中心删除与标记关联的通知。
有关使用 AppNotificationBuilder API 创建应用通知 UI 的指导,请参阅 应用通知内容。
有关应用通知的 XML 架构的参考信息,请参阅 应用通知内容架构。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈