Compartilhar via


CoreWebView2Notification Class

An object that represents a HTML Notification object.

Summary

Members Description
BadgeUri A string containing the URI of the image used to represent the notification when there isn't enough space to display the notification itself.
Body A string representing the body text of the notification.
BodyImageUri A string containing the URI of an image to be displayed in the notification.
Direction The text direction in which to display the notification.
IconUri A string containing the URI of an icon to be displayed in the notification.
IsSilent Indicates whether the notification should be silent -- i.e., no sounds or vibrations should be issued, regardless of the device settings.
Language The notification's language, as intended to be specified using a string representing a language tag (such as en-US) according to BCP47.
RequiresInteraction A boolean value indicating that a notification should remain active until the user clicks or dismisses it, rather than closing automatically.
ShouldRenotify Indicates whether the user should be notified after a new notification replaces an old one.
Tag A string representing an identifying tag for the notification.
Timestamp
Title The title of the notification.
VibrationPattern Activates a persistent notification with a given action with the specified action index.
ReportClicked The host may run this to report the notification has been clicked, and it will cause the click event to be raised for non-persistent notifications.
ReportClosed The host may run this to report the notification was dismissed, and it will cause the close event to be raised for non-persistent notifications.
ReportShown The host may run this to report the notification has been displayed and it will cause the show event to be raised for non-persistent notifications.
CloseRequested This event is raised when the notification is closed by the web code, such as through notification.close().

Properties

BadgeUri

readonly string BadgeUri

A string containing the URI of the image used to represent the notification when there isn't enough space to display the notification itself. The default value is an empty string.

Body

readonly string Body

A string representing the body text of the notification. The default value is an empty string.

BodyImageUri

readonly string BodyImageUri

A string containing the URI of an image to be displayed in the notification. The default value is an empty string.

Direction

readonly CoreWebView2TextDirectionKind Direction

The text direction in which to display the notification. This corresponds to Notification.dir DOM API. The default value is CoreWebView2TextDirectionKind.Default.

IconUri

readonly string IconUri

A string containing the URI of an icon to be displayed in the notification. The default value is an empty string.

IsSilent

readonly bool IsSilent

Indicates whether the notification should be silent -- i.e., no sounds or vibrations should be issued, regardless of the device settings. This corresponds to Notification.silent DOM API. The default value is false.

Language

readonly string Language

The notification's language, as intended to be specified using a string representing a language tag (such as en-US) according to BCP47. Note that no validation is performed on this property and it can be any string the notification sender specifies. This corresponds to Notification.lang DOM API. The default value is an empty string.

RequiresInteraction

readonly bool RequiresInteraction

A boolean value indicating that a notification should remain active until the user clicks or dismisses it, rather than closing automatically. This corresponds to Notification.requireInteraction DOM API. Note that you may not be able to necessarily implement this due to native API limitations. The default value is false.

ShouldRenotify

readonly bool ShouldRenotify

Indicates whether the user should be notified after a new notification replaces an old one. This corresponds to Notification.renotify DOM API. The default value is false.

Tag

readonly string Tag

A string representing an identifying tag for the notification. This corresponds to Notification.tag DOM API. The default value is an empty string.

Timestamp

readonly double Timestamp

Title

readonly string Title

The title of the notification.

VibrationPattern

readonly IVectorView<uint64_t> VibrationPattern

Activates a persistent notification with a given action with the specified action index.

Methods

ReportClicked

void ReportClicked()

The host may run this to report the notification has been clicked, and it will cause the click event to be raised for non-persistent notifications. You must not run this unless you are handling the CoreWebView2.NotificationReceived. API throws COMException with error code of HRESULT_FROM_WIN32(ERROR_INVALID_STATE) if CoreWebView2NotificationReceivedEventArgs.Handled is false or CoreWebView2Notification.ReportShown has not been run when this is called.

ReportClosed

void ReportClosed()

The host may run this to report the notification was dismissed, and it will cause the close event to be raised for non-persistent notifications. You must not run this unless you are handling the CoreWebView2.NotificationReceived. API throws COMException with error code of HRESULT_FROM_WIN32(ERROR_INVALID_STATE) if CoreWebView2NotificationReceivedEventArgs.Handled is false or CoreWebView2Notification.ReportShown has not been run when this is called.

ReportShown

void ReportShown()

The host may run this to report the notification has been displayed and it will cause the show event to be raised for non-persistent notifications. You must not run this unless you are handling the CoreWebView2.NotificationReceived. API throws COMException with error code of HRESULT_FROM_WIN32(ERROR_INVALID_STATE) if CoreWebView2NotificationReceivedEventArgs.Handled is false when this is called.

Events

CloseRequested

This event is raised when the notification is closed by the web code, such as through notification.close(). You don't need to call CoreWebView2Notification.ReportClosed since this is coming from the web code.

Type: TypedEventHandler<CoreWebView2Notification, Object>

Referenced by