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