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

Log the notification reply if one exists #37

Merged
merged 2 commits into from Jun 4, 2018

Conversation

anitawoodruff
Copy link
Contributor

No description provided.

@@ -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 + '"');
}
Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Done)

@@ -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) {
Copy link
Owner

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 += ')';
}

Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Done)

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, it's explicit :)

@beverloo beverloo merged commit b84a759 into beverloo:master Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants