0

I am trying to generate a web push notification for an admin user based on the actions of a group of specific users.

So basically a user tries to generate a report by clicking a button but it asks for a code. On the background it sends an email or a message to the admin with a specific six digit code. He then calls up the user who wants the report and tells him the code. The user submits the code in the form in front of him and can now access the report.

However, the admin user wants to see the code in the notification box that should pop up on the corner of the screen. How can I achieve this? Do I need to learn Django Channels for this?

MiniGunnR
  • 5,590
  • 8
  • 42
  • 66
  • 1
    Take a look at https://github.com/django-notifications/django-notifications maybe this helps you. – Nerade Feb 22 '17 at 07:46
  • You can either use a websockets solution such as Django Channels, or have a piece of javascript on the page which regularly polls the server for new notifications. – ChidG Feb 22 '17 at 07:50
  • I would use JavaScript to achieve this. It seems `django-notifications` is the easiest alternative. – Ev. Feb 22 '17 at 07:57
  • @ChidG Are you talking about sending requests to server at an interval to check whether there's a notification? That won't work if the browser is closed, right? – MiniGunnR Feb 22 '17 at 08:30
  • @Nerade Is this going to show notification box on the corner of the screen even if the browser is closed? – MiniGunnR Feb 22 '17 at 08:33
  • @MiniGunnR i dont even know how this should be possible? If the browser is closed none of your code is run on client side, because there is no client anymore. You would need to implement a standalone application or use other tools already serving such a feature. – Nerade Feb 22 '17 at 11:44
  • as @Nerade says - no, it won't show notifications if the browser is closed. If you need desktop notifications outside of the browser you might consider coding a desktop client in electron or something similar. – ChidG Feb 23 '17 at 01:36
  • @ChidG But I want to do something like Facebook desktop notifications. It shows your notifications to you even if your browser is closed, without the client having a native application. – MiniGunnR Feb 23 '17 at 09:41
  • There's an answer to this question referring to using Service Workers to achieve what you want. This is a pretty advanced technique but can be done. http://stackoverflow.com/questions/27221203/send-desktop-notifications-in-chrome-or-firefox-from-a-closed-web-app – ChidG Feb 24 '17 at 02:18

1 Answers1

0

with Firefox/Chrome use django-webpush

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/33901986) – SiKing Feb 28 '23 at 22:20