Skip to content

Allow push notifications in user's notifications settings#8749

Closed
quinHD wants to merge 14 commits intodevelopfrom
feature/allow-push-notifications
Closed

Allow push notifications in user's notifications settings#8749
quinHD wants to merge 14 commits intodevelopfrom
feature/allow-push-notifications

Conversation

@quinHD
Copy link
Copy Markdown
Contributor

@quinHD quinHD commented Jan 25, 2022

🎩 What? Why?

This PR adds option to the user to allow push notifications in the profile panel.

📌 Related Issues

Issue #8489

Testing

You can test this feature visiting /notifications_settings. When you enable Push notifications you have to allow also notifications in the browser popup.

Acceptance criteria
  • Given that I'm a registered participant and my browser allows push notifications
    When I go to "My account" -> "Notifications settings"
    Then I see a section called "Push notifications"
    and when I check this setting
    Then I get asked for permission to receive Push notifications
  • Given that I'm a registered participant and my browser don't allows push notifications
    When I go to "My account" -> "Notifications settings"
    Then I don't see the "Push notifications" section.
  • Given that I'm a registered participant, my browser allows push notifications and I've revoked this permission in my browser
    When I go to "My account" -> "Notifications settings"
    Then I see a section called "Push notifications" with the following message:
 To get notifications from Decidim, you\u2019ll need to allow them in your browser settings first.
  • Given that I'm a registered participant, my browser allows push notifications and I've accepted the Push notifications
    When I go to "My account" -> "Notifications settings"
    Then I see a section called "Push notifications"
    and when I uncheck this setting
    Then I've revoked permission to receive Push notifications

📋 Checklist

🚨 Please review the guidelines for contributing to this repository.

  • CONSIDER adding a unit test if your PR resolves an issue.
  • ✔️ DO check open PR's to avoid duplicates.
  • ✔️ DO keep pull requests small so they can be easily reviewed.
  • ✔️ DO build locally before pushing.
  • ✔️ DO make sure tests pass.
  • ✔️ DO make sure any new changes are documented in docs/.
  • ✔️ DO add and modify seeds if necessary.
  • ✔️ DO add CHANGELOG upgrade notes if required.
  • ✔️ DO add to GraphQL API if there are new public fields.
  • ✔️ DO add link to MetaDecidim if it's a new feature.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

📷 Screenshots

Please add screenshots of the changes you're proposing
image
♥️ Thank you!

@quinHD quinHD self-assigned this Jan 25, 2022
@andreslucena andreslucena added project: PWA Barcelona City Council contract module: core type: feature labels Jan 26, 2022
@quinHD quinHD marked this pull request as ready for review January 27, 2022 09:50
@quinHD quinHD linked an issue Jan 28, 2022 that may be closed by this pull request
4 tasks
@quinHD quinHD force-pushed the feature/allow-push-notifications branch from 3553450 to 041f069 Compare February 2, 2022 16:47
@andreslucena
Copy link
Copy Markdown
Member

Can you fill the PR template @quinHD 🙏🏽?

@andreslucena andreslucena requested a review from ferblape February 7, 2022 08:41
ferblape
ferblape previously approved these changes Feb 15, 2022
@ferblape
Copy link
Copy Markdown
Contributor

@quinHD could you review the broken spec? The rest is fine, so ping product when ready

@ferblape
Copy link
Copy Markdown
Contributor

Ready to review @andreslucena

Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

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

Some small changes to apply 🙏🏽

@andreslucena
Copy link
Copy Markdown
Member

I was trying to force the notification browser consent dialog but couldn't do it locally, so I'd probably need to check it in the staging server. Let me know when you have it please.

@quinHD quinHD force-pushed the feature/allow-push-notifications branch from a7de219 to 42411b8 Compare February 24, 2022 16:50
@quinHD quinHD changed the title Allow push notifications Allow push notifications in user's menu Feb 24, 2022
Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

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

I've just tested one last time and the flow is exactly what I had in mind, congratulations!!

I have a couple doubts and a minor CSS reflow that we need to change.

@andreslucena andreslucena linked an issue Mar 29, 2022 that may be closed by this pull request
@andreslucena
Copy link
Copy Markdown
Member

I see that there's a missing Acceptance Criteria:

Given that I'm a registered participant and my browser don't allows push notifications
When I go to "My account" -> "Notifications settings"
Then I don't see the "Push notifications" section.

This is with Opera Mini:

image

@quinHD quinHD force-pushed the feature/allow-push-notifications branch from 10e6153 to a687708 Compare April 20, 2022 13:10
@andreslucena andreslucena added the release: v0.27 Issues or PRs that need to be tackled for v0.27 label Apr 21, 2022
@andreslucena
Copy link
Copy Markdown
Member

@quinHD I see that you have two flaky tests:

  1. It was about NPM and a lost connection server side, I run it again and now it works
  2. There was a problem related with seeds and passwords, that comes after Enforce password validation rules on 'Forgot your password?' form #9090. It should be fixed when Fix flaky factory when the user's sequence name arrives to 1234 #9167 it's merged, but meanwhile I retried and it works again.

@andreslucena
Copy link
Copy Markdown
Member

Is this ready to be reviewed @quinHD? Have you deploy it to https://decidim.populate.tools? Is the bug from my last comment fixed?

@quinHD
Copy link
Copy Markdown
Contributor Author

quinHD commented Apr 21, 2022

Yes to all. The only thing to keep in mind is that parte of the logic of the allow push notifications is modified in the other PR

@andreslucena
Copy link
Copy Markdown
Member

@quinHD I still see the same behavior with Opera Mini: it shows the checkbox, and it doesn't ask for my permissions at the browser because it doesn't support it.

@quinHD
Copy link
Copy Markdown
Contributor Author

quinHD commented Apr 21, 2022

@quinHD I still see the same behavior with Opera Mini: it shows the checkbox, and it doesn't ask for my permissions at the browser because it doesn't support it.

Hmm, I think the problem is that the browser also doesn't support new JS features, so it breaks the flow. This way, when it's going to check if it has to render the check button or not, it can't because there's an error.
Let me ask if there's any work around.

@andreslucena andreslucena changed the title Allow push notifications in user's menu Allow push notifications in user's notifications settings Apr 21, 2022
@andreslucena
Copy link
Copy Markdown
Member

Just talked about the Opera Mini thing that I was mentioning in my last couple of comments with @quinHD outside of GitHub, and it seems like this is only a thing with Opera Mini:

  • Safari in an iPad Mini: it doesn't support it, and it isn't shown
  • IE11 in a Win8 VM: it doesn't support it, and it isn't shown
  • Opera in a Win11 VM: it supports it, it's shown, and it also shows the browser notification

So as discussed, in this particular case as it seems a problem with this particular browser, and it isn't a browser with much traction, we'll do a hard-coded User Agent reject list or a similar strategy.

@quinHD
Copy link
Copy Markdown
Contributor Author

quinHD commented Apr 25, 2022

Just talked about the Opera Mini thing that I was mentioning in my last couple of comments with @quinHD outside of GitHub, and it seems like this is only a thing with Opera Mini:

  • Safari in an iPad Mini: it doesn't support it, and it isn't shown
  • IE11 in a Win8 VM: it doesn't support it, and it isn't shown
  • Opera in a Win11 VM: it supports it, it's shown, and it also shows the browser notification

So as discussed, in this particular case as it seems a problem with this particular browser, and it isn't a browser with much traction, we'll do a hard-coded User Agent reject list or a similar strategy.

Done! I added a User Agent rejection. Opera mini doesn't have its own User Agent. So I use the opera identifier and the mobile tag. I think it will affect also the Opera mobile browser.


class AddAllowPushNotificationsToUsers < ActiveRecord::Migration[6.0]
def change
add_column :decidim_users, :allow_push_notifications, :boolean, default: false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After #8757 we have the notifications_settings JSONB column.

I see that's actually being used by the related PR #8774, so I think it makes sense to also migrate this column to notifications_settings, so it's all consistent. I know it can be a bit more of an effort but in the long term it's going to be there, so I think it's better to do it sooner than later. What do you think @quinHD?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

since this column will disappear in the other PR. We have considered that this PR can be closed and its functionality will be taken over by the push-notifications-to-client PR.

@quinHD quinHD closed this Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: core project: PWA Barcelona City Council contract release: v0.27 Issues or PRs that need to be tackled for v0.27

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notifications settings reflow on mobile Ask permission to client for Push Notifications

4 participants