共用方式為


interface ICoreWebView2Notification

interface ICoreWebView2Notification
  : public IUnknown

This is the ICoreWebView2Notification that represents a HTML Notification object.

Summary

Members Descriptions
add_CloseRequested Add an event handler for the CloseRequested event.
get_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.
get_Body A string representing the body text of the notification.
get_BodyImageUri A string containing the URI of an image to be displayed in the notification.
get_Direction The text direction in which to display the notification.
get_IconUri A string containing the URI of an icon to be displayed in the notification.
get_IsSilent Indicates whether the notification should be silent – i.e., no sounds or vibrations should be issued, regardless of the device settings.
get_Language The notification's language, as intended to be specified using a string representing a language tag (such as en-US) according to BCP47.
get_RequiresInteraction A boolean value indicating that a notification should remain active until the user clicks or dismisses it, rather than closing automatically.
get_ShouldRenotify Indicates whether the user should be notified after a new notification replaces an old one.
get_Tag A string representing an identifying tag for the notification.
get_Timestamp Indicates the time at which a notification is created or applicable (past, present, or future) as the number of milliseconds since the UNIX epoch.
get_Title The title of the notification.
GetVibrationPattern Gets the vibration pattern for devices with vibration hardware to emit.
remove_CloseRequested Remove an event handler previously added with add_CloseRequested.
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 and the notificationclick event for 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 and the notificationclose event for 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.

Applies to

Product Introduced
WebView2 Win32 1.0.2739.15
WebView2 Win32 Prerelease 1.0.2730

Members

add_CloseRequested

Add an event handler for the CloseRequested event.

public HRESULT add_CloseRequested(ICoreWebView2NotificationCloseRequestedEventHandler * eventHandler, EventRegistrationToken * token)

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

get_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.

public HRESULT get_BadgeUri(LPWSTR * value)

The default value is an empty string.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_Body

A string representing the body text of the notification.

public HRESULT get_Body(LPWSTR * value)

The default value is an empty string.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_BodyImageUri

A string containing the URI of an image to be displayed in the notification.

public HRESULT get_BodyImageUri(LPWSTR * value)

The default value is an empty string.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_Direction

The text direction in which to display the notification.

public HRESULT get_Direction(COREWEBVIEW2_TEXT_DIRECTION_KIND * value)

This corresponds to Notification.dir DOM API. The default value is COREWEBVIEW2_TEXT_DIRECTION_KIND_DEFAULT.

get_IconUri

A string containing the URI of an icon to be displayed in the notification.

public HRESULT get_IconUri(LPWSTR * value)

The default value is an empty string.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_IsSilent

Indicates whether the notification should be silent – i.e., no sounds or vibrations should be issued, regardless of the device settings.

public HRESULT get_IsSilent(BOOL * value)

This corresponds to Notification.silent DOM API. The default value is FALSE.

get_Language

The notification's language, as intended to be specified using a string representing a language tag (such as en-US) according to BCP47.

public HRESULT get_Language(LPWSTR * value)

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.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_RequiresInteraction

A boolean value indicating that a notification should remain active until the user clicks or dismisses it, rather than closing automatically.

public HRESULT get_RequiresInteraction(BOOL * value)

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.

get_ShouldRenotify

Indicates whether the user should be notified after a new notification replaces an old one.

public HRESULT get_ShouldRenotify(BOOL * value)

This corresponds to Notification.renotify DOM API. The default value is FALSE.

get_Tag

A string representing an identifying tag for the notification.

public HRESULT get_Tag(LPWSTR * value)

This corresponds to Notification.tag DOM API. The default value is an empty string.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_Timestamp

Indicates the time at which a notification is created or applicable (past, present, or future) as the number of milliseconds since the UNIX epoch.

public HRESULT get_Timestamp(double * value)

get_Title

The title of the notification.

public HRESULT get_Title(LPWSTR * value)

The caller must free the returned string with CoTaskMemFree. See API Conventions.

GetVibrationPattern

Gets the vibration pattern for devices with vibration hardware to emit.

public HRESULT GetVibrationPattern(UINT32 * count, UINT64 ** vibrationPattern)

The vibration pattern can be represented by an array of 64-bit unsigned integers describing a pattern of vibrations and pauses. See Vibration API for more information. This corresponds to Notification.vibrate DOM API. An empty array is returned if no vibration patterns are specified.

remove_CloseRequested

Remove an event handler previously added with add_CloseRequested.

public HRESULT remove_CloseRequested(EventRegistrationToken token)

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 and the notificationclick event for persistent notifications.

public HRESULT ReportClicked()

Use ReportClickedWithActionIndex to specify an action to activate a persistent notification. You must not run this unless you are handling the NotificationReceived event. Returns HRESULT_FROM_WIN32(ERROR_INVALID_STATE) if Handled is FALSE or ReportShown has not been run when this is called.

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 and the notificationclose event for persistent notifications.

public HRESULT ReportClosed()

You must not run this unless you are handling the NotificationReceived event. Returns HRESULT_FROM_WIN32(ERROR_INVALID_STATE) if Handled is FALSE or ReportShown has not been run when this is called.

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.

public HRESULT ReportShown()

You must not run this unless you are handling the NotificationReceived event. Returns HRESULT_FROM_WIN32(ERROR_INVALID_STATE) if Handled is FALSE when this is called.