-
Notifications
You must be signed in to change notification settings - Fork 43
Add Declarative Web Push #385
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
base: gh-pages
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see more explanatory text attached to this sort of change. (In the spec, not the PR, for avoidance of doubt.)
From what I can see, a message is opportunistically parsed as JSON. If it parses and there is a "web_push": 9001 (?!) attribute, the browser attempts to make a notification. If that works, the notification is shown.
There is also a mutable attribute attached, which would allow the SW the option of intercepting the notification and tweaking it before it is shown. That would somewhat negate the benefits from a purely declarative notification, so it seems an unnecessary feature (the app could save the "web_push": 9001 bytes and just make a notification for itself).
index.html
Outdated
If a notification has been shown through {{showNotification()}} at this | ||
point, then abort these steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems non-ideal. I don't know how this is supposed to work, but this requires a trap in showNotification
to track, but you aren't monkey-patching that. Does preventDefault
not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, this statement is monkey patching that. Certainly seems reasonable to tidy it up though. (preventDefault()
wouldn't guarantee that a notification is shown.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once whatwg/notifications#227 lands this can be checked here instead of showNotification()
. Does that seem reasonable? Anything else remaining?
7b3b218
to
4f6bd92
Compare
d6af68d
to
56c5432
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err, is this case sensitive or can we make things consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with ReSpec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcoscaceres, do you know?
This introduces a new feature whereby push messages conforming to a certain JSON format directly create an end user notification and show it (possibly preceded by an enhanced push event). In addition to showing a notification, the app badge can be updated as well. This builds on whatwg/notifications#213 which adds URL members to notifications. Exposing PushManager outside of service workers is handled by #393.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly fine with a few changes. We explicitly did not cover the app badge part of this PR though.
<li> | ||
<p> | ||
If |appBadgeSet| is false, then <a href= | ||
"https://github.com/w3c/badging/issues/111">w3c/badging #111</a>... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This part is incomplete)
</li> | ||
<li> | ||
<p> | ||
Let |declarativeResult| be the result of running the [=/declarative push message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens after "If |registration| is not found, abort these steps." step above. Either #393 or this PR should fix that.
<li> | ||
<p> | ||
If |declarativeResult|'s [=declarative push message parser result/mutable=] | ||
is true: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should check the existence of registration
too?
<li> | ||
<p> | ||
<a>Fire a functional event</a> named "`push`" using <a>PushEvent</a> on | ||
|registration| with the following properties: | ||
</p> | ||
<dl> | ||
<dt> | ||
`data` | ||
{{PushEvent//data}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{PushEvent//data}} | |
{{PushEvent/data}} |
This introduces a new feature whereby push messages conforming to a certain JSON format directly create an end user notification and show it (possibly preceded by an enhanced push event).
In addition to showing a notification, the app badge can be updated as well.
This builds on whatwg/notifications#213 which adds URL members to notifications.
Exposing PushManager outside of service workers is #393.
The following tasks have been completed:
Implementer support:
Preview | Diff