AppNotificationScenario 枚举

定义

指定应用通知的方案,这会导致系统调整某些通知行为,以便为指定的方案提供一致的体验。

public enum class AppNotificationScenario
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract, 65536)]
enum class AppNotificationScenario
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract), 65536)]
public enum AppNotificationScenario
var value = Microsoft.Windows.AppNotifications.Builder.AppNotificationScenario.default
Public Enum AppNotificationScenario
继承
AppNotificationScenario
属性

字段

Alarm 2

警报方案。

Default 0

默认方案。

IncomingCall 3

传入呼叫方案。

Reminder 1

提醒方案。

Urgent 4

紧急方案。

示例

以下示例演示如何在应用通知的 XML 有效负载中设置通知方案。

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .SetScenario(AppNotificationScenario.Reminder)
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

生成的 XML 有效负载:

<toast scenario='reminder'>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
</toast>

注解

通过调用 AppNotificationBuilder.SetScenario 设置应用通知 XML 有效负载的方案。

紧急方案值仅在 Windows 10 版本 19041 及更高版本上受支持。 调用 IsUrgentScenarioSupported 以确定在运行时当前设备上是否支持紧急方案。

有关使用 AppNotificationBuilder API 创建应用通知 UI 的指导,请参阅 应用通知内容

有关应用通知的 XML 架构的参考信息,请参阅 应用通知内容架构

适用于