Re: [w3c/push-api] Add Declarative Web Push (PR #385)

@saschanaz commented on this pull request.

Can we split `mutable` out of this PR for now?

> @@ -56,7 +56,8 @@
       };
     </script>
   </head>
-  <body data-cite="service-workers FILEAPI secure-contexts hr-time permissions ECMASCRIPT">
+  <body data-cite=
+  "service-workers FILEAPI secure-contexts hr-time permissions ECMASCRIPT NOTIFICATIONS BADGING">

Err, is this case sensitive or can we make things consistent?

> +                  </p>
+                </dd>
+                <dt>
+                  <code>require_interaction</code>
+                </dt>
+                <dd>
+                  <p>
+                    A boolean.
+                  </p>
+                </dd>
+                <dt>
+                  <code>data</code>
+                </dt>
+                <dd>
+                  <p>
+                    Any JSON value.

Do we know how many existing callers set binary data (arraybuffer/blob etc) here? One can still use base64 though (and Gecko serializes it to base64 anyway).

> +          <ol>
+            <li>
+              <p>
+                Let <var>message</var> be the result of [=parse JSON bytes to an Infra
+                value|parsing JSON bytes to an Infra value=] given <var>bytes</var>. If that throws
+                an exception, then return failure.
+              </p>
+            </li>
+            <li>
+              <p data-cite="INFRA">
+                If <var>message</var> is not a [=/map=], then return failure.
+              </p>
+            </li>
+            <li>
+              <p>
+                If <var>message</var>["`web_push`"] does not [=map/exist=] or is not 8030, then

Is this kind of check common for web APIs handling JSON payload? Feels sorta random, I wonder what about using [JSON-LD](https://www.w3.org/TR/json-ld/) like `"@context": "https://www.w3.org/ns/web-push"` as [ActivityPub does](https://w3c.github.io/activitypub/#Overview).

> +                </dt>
+                <dd>
+                  <p>
+                    A boolean.
+                  </p>
+                </dd>
+                <dt>
+                  <code>silent</code>
+                </dt>
+                <dd>
+                  <p>
+                    A boolean.
+                  </p>
+                </dd>
+                <dt>
+                  <code>require_interaction</code>

Sorta understandable from infra point but I guess the callers would have to deal with this casing in that case, like:

```js
onpush = async (ev) => {
  // Err, our little cute browser doesn't support declarative web push,
  // so we are here for nice progressive web.
  const { notification } = await ev.data.json();
  
  // This will mostly work until you use requireInteraction.
  // await registration.showNotification(notification.title, notification);
  
  const notificationOptions = {
    ...notification,
    requireInteraction: notification.require_interaction, // 😅
  };
  await registration.showNotification(notification.title, notificationOptions);
};
```

I wonder it would make sense to have an exception here to prevent extra boilerplate and head-scratching?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/push-api/pull/385#pullrequestreview-2606180526
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/push-api/pull/385/review/2606180526@github.com>

Received on Monday, 10 February 2025 16:35:51 UTC