-
Notifications
You must be signed in to change notification settings - Fork 86
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
Log the notification reply if one exists #37
Conversation
@@ -20,6 +20,9 @@ self.addEventListener('activate', function(event) { | |||
self.addEventListener('fetch', function(event) {}); | |||
|
|||
self.addEventListener('notificationclick', function(event) { | |||
if (event.reply) { | |||
alert('User replied: "' + event.reply + '"'); | |||
} |
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.
You'll want to add this around line 59, currently it doesn't do anything.
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.
Ah I see, so you can't show an alert from a service worker, but you can from a page, hence the postMessage business..
I'll also add instructions to the test survey to select the 'Display an alert' reaction setting then.
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.
(Done)
1512649
to
5762f80
Compare
@@ -54,6 +54,9 @@ self.addEventListener('notificationclick', function(event) { | |||
var message = 'Clicked on "' + notification.title + '"'; | |||
if (event.action) | |||
message += ' (action "' + event.action + '")'; | |||
if (event.reply) { |
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.
Should we allow distinguishing between NULL and the empty string? Could do something like:
if (event.action) {
message += ' (action: "' + event.action + '", reply: ';
message += event.reply === null ? 'null' : '"' + event.reply + '"';
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 does mean we will get "reply: undefined" when experimental-web-platform-features are disabled atm, but maybe that's okay?
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.
(Done)
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.
Yeah, it's explicit :)
* Log the notification reply if one exists * log if it's null
* Log the notification reply if one exists * log if it's null
No description provided.