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

@dimitribouniol commented on this pull request.



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

I'll add that as a server library tracking this proposal, my [adoption documentation](https://github.com/mochidev/swift-webpush/blob/aa06736b6e40f4e8e47e7e4c85655b93832a0097/README.md?plain=1#L203-L219) looks similarly to @saschanaz's, and I'd similarly push for aligning the property names so they could be passed as-is to `showNotification()`, if only to easy the migration story the community would need to push for to get this adopted:

```js
self.addEventListener('push', function(event) {
    const data = event.data?.json() ?? {};
    event.waitUntil((async () => {
        const notification = data.notification ?? {}
        /// Try parsing the data, otherwise use fallback content. DO NOT skip sending the notification, as you must display one for every push message that is received or your subscription will be dropped.
        const title = notification.title ?? "Your App Name";
        const body = notification.body ?? "New Content Available!";
        
        await self.registration.showNotification(title, { 
            body,
            requireInteraction: notification.require_interaction ?? false,
            ...notification,
        });
    })());
});
```

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

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

Received on Sunday, 2 March 2025 11:53:20 UTC