Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Review: Web Notification #3186

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add DataAsJson and TryGetDataAsString
  • Loading branch information
peiche-jessica committed Jan 9, 2023
commit b8395cb0badd44722ef1554d1f308565dea10931
30 changes: 23 additions & 7 deletions specs/WebNotification.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,27 @@ interface ICoreWebView2Notification : IUnknown {
/// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
[propget] HRESULT Body([out, retval] LPWSTR* value);

/// Returns an IDataObject that represents a structured clone of the
/// notification's data.
/// Returns `null` if the optional Notification property does not exist.
[propget] HRESULT Data([out, retval] IDataObject** value);
/// Returns a JSON string representing the notification data.
/// [Notification.data](https://developer.mozilla.org/docs/Web/API/Notification/data)
/// DOM API is arbitrary data the notification sender wants associated with
/// the notification and can be of any data type.
/// The default value is an empty string.
///
/// The caller must free the returned string with `CoTaskMemFree`. See
/// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
[propget] HRESULT DataAsJson([out, retval] LPWSTR* value);

/// If the notification data is a string
/// type, this method returns the value of that string. If the notification data
/// is some other kind of JavaScript type this method fails with `E_INVALIDARG`.
/// [Notification.data](https://developer.mozilla.org/docs/Web/API/Notification/data)
/// DOM API is arbitrary data the notification sender wants associated with
/// the notification and can be of any data type.
/// The default value is an empty string.
///
/// The caller must free the returned string with `CoTaskMemFree`. See
/// [API Conventions](/microsoft-edge/webview2/concepts/win32-api-conventions#strings).
HRESULT TryGetDataAsString([out, retval] LPWSTR* value);

/// The text direction in which to display the notification.
/// This corresponds to
Expand Down Expand Up @@ -632,9 +649,8 @@ namespace Microsoft.Web.WebView2.Core
Boolean Silent { get; };
Double Timestamp { get; };
IVectorView<UInt64> Vibrate { get; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Vibrate" sounds like bool(s). Looks like this was update to VibrationPattern in the C++ version above?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks. Please also update similar to above.

// TODO: What should the proper data type be for
// CoreWebView2Notification.Data? We use IDataObject for COM/C++.
// Data { get; };
String DataAsJson { get; };
String TryGetDataAsString();

event Windows.Foundation.TypedEventHandler<CoreWebView2Notification, Object> CloseRequested;

Expand Down