AppNotificationBuilder.IsUrgentScenarioSupported 方法

定义

返回一个值,该值指示当前设备上是否支持紧急应用通知方案。

public:
 static bool IsUrgentScenarioSupported();
 static bool IsUrgentScenarioSupported();
public static bool IsUrgentScenarioSupported();
function isUrgentScenarioSupported()
Public Shared Function IsUrgentScenarioSupported () As Boolean

返回

Boolean

bool

如果当前设备支持紧急应用通知方案,则为 True;否则为 false。

示例

以下示例演示如何检查是否支持紧急应用通知方案。

var builder = new AppNotificationBuilder()
    .AddText("Notification text.");

if (AppNotificationBuilder.IsUrgentScenarioSupported())
{
    builder.SetScenario(AppNotificationScenario.Urgent);
}

AppNotificationManager.Default.Show(builder.BuildNotification());

如果支持紧急方案,则为生成的 XML 有效负载:

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

注解

AppNotificationBuilder.SetScenario 方法允许你指定 AppNotificationScenario 枚举中的方案之一,这会使系统调整一些通知行为,以便为指定的方案提供一致的体验。 紧急方案值仅在 Windows 10 版本 19041 及更高版本上受支持。 使用此方法可以在运行时确定当前设备上是否支持紧急方案。

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

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

适用于