Push Notifications Using Node.js & Service Worker

Поділитися
Вставка
  • Опубліковано 16 вер 2024
  • In this video we will create push notification capability using Node.js without any 3rd party services. We will achieve this using web-push, the push/notifications api and service workers.
    Code:
    github.com/bra...
    Webpush Repo:
    github.com/web...
    Helpful Articles:
    developers.goo...
    developers.goo...
    / a-beginners-guide-to-s...
    💖 Become a Patron: Show support & get perks!
    / traversymedia
    Website & Udemy Courses
    www.traversymed...
    Follow Traversy Media:
    / traversymedia
    / traversymedia
    / traversymedia

КОМЕНТАРІ • 277

  • @techdave99
    @techdave99 6 років тому +52

    Edge 17 (in the april windows 10 update) has service workers. In Edge 16, workers are installed by enabling the 'Enable Services Workers' flag.

    • @TraversyMedia
      @TraversyMedia  6 років тому +4

      techdave99 awesome, thank you for clarifying that

    • @manojsinghrawat6069
      @manojsinghrawat6069 3 роки тому

      @Reynaldo that's a work of notification , why would it show same notification again and again

  • @ThiagoVieira91
    @ThiagoVieira91 6 років тому +17

    ZOMG! I was in need of this tutorial for a college class. You saved me, Brad! ✊

    • @TraversyMedia
      @TraversyMedia  6 років тому +13

      That's awesome they are actually doing this stuff in college. I say that because from what I have seen it is a lot of older and theory based technology

    • @patrickRotmg
      @patrickRotmg 6 років тому +5

      In my college, they teach Node.js, Angular, Gulp, and stuff like that! Just in the beginning it was Java

  • @stephh4392
    @stephh4392 6 років тому +11

    I love this kind of video, more full-stack, more back end web, excellent!!!Thank u Brad!

  • @superasn
    @superasn 5 років тому +1

    This is the best most complete video tutorials on web notifications!

  • @alanthinks
    @alanthinks 6 років тому +1

    Greetings from Miami! I have a Start-Up Culture Channel and I'm also a Developer.. LEARNING A LOT FROM YOU T! THANK YOU!

  • @saurabhkashyap7577
    @saurabhkashyap7577 6 років тому +2

    Thank you I am waiting for push notification basic video from you , this video clear my all basic doubts. And please release soon your PWA crash course. Hope we really enjoy that series’s of video , and thank you man

  • @billsb5873
    @billsb5873 6 років тому +2

    I'm struggling with notifications for a week or so.. specifically with firebase cloud messaging/react. I would love to see your next videos on pwa's or specifically firebase cloud messaging. I found documentation to be a bit confusing. Thank you for this video on node/vapid. It was really useful.

  • @sagarmaheshwary3150
    @sagarmaheshwary3150 6 років тому +6

    That really helped. You should do tutorial on pwa for beginners.

  • @lonewolfcoding5208
    @lonewolfcoding5208 Рік тому +1

    no matter the coding is
    server is most crucial computer in the world it handles the most users specially on the cloud

  • @pygemssoftware4254
    @pygemssoftware4254 2 роки тому

    Another gem from traversy. On an abstruse subject made simple

  • @jdalzate7390
    @jdalzate7390 6 років тому +6

    Great Video Brad. I would love a video showing us how to translate our Web page language.

  • @nishanthbhat
    @nishanthbhat 6 років тому +4

    Thank you Brad! Your always bring something new out of the box. I really enjoy your videos. Learning lot from them. Keep bringing such quality stuff 👍. Once again thank you. 😊

  • @PandemicGameplay
    @PandemicGameplay 6 років тому +1

    It;s good to do videos on things that do not rely on external libraries. Security vulnerabilities are becoming very high for many third party libraries and often times they aren't even really needed.

  • @boscocorrea1895
    @boscocorrea1895 6 років тому +36

    Please...! do a pwa tutorials

  • @Ibanezyt
    @Ibanezyt 6 років тому +1

    Greetings from Cape Town. Awesome tutorial, appreciate it! Thanks

  • @tareqdevdiary
    @tareqdevdiary 5 років тому +1

    I'm gonna use it for one of my university project, thank you sir!

  • @eugenemusebe4963
    @eugenemusebe4963 6 років тому

    This came at the correct time. You are amazing Brad

  • @juan193
    @juan193 6 років тому +1

    Hey man! Been following your videos for a while and i've gotta say you're one of the best teachers out there! You've helped me a bunch! I got a question: Would you consider doing a nativescript/typescript/any DB and API tech? Again, many thanks!

  • @mohammadakbar32
    @mohammadakbar32 6 років тому +3

    thanks Brad! amazing content as always! essential topic.
    God bless you.

  • @vlaaristil5738
    @vlaaristil5738 4 роки тому

    This push thing is so interesting. I had no idea I could squeeze out extra revenue from the same amount of traffic by simply adding push monetization to my sites. Currently I use MonadPlug, works great with AdSense.

  • @doniyority
    @doniyority 5 років тому +9

    Dear Brad, can you tell me how i can make notification to react native app using node js?

  • @slyrockyballboa
    @slyrockyballboa 3 роки тому +1

    Great video! Thanks
    Push notification recived only if you refresh browser, how to achive without browser refresh?

  • @kennymoreno5735
    @kennymoreno5735 6 років тому

    I have just became a Patreon supporter thank you very much Brad.

  • @tristanphillips7569
    @tristanphillips7569 2 роки тому

    Thanks! This is just what I was looking for. Nicely explained.

  • @arissbandoss4478
    @arissbandoss4478 3 роки тому +2

    Nice tutorial. But does it require the user to have the web page active to see this?? Can we do it when the user is not even in the browser?? Thanks

  • @ramganesh1814
    @ramganesh1814 5 років тому +1

    This is a great video. Thanks for that. You explained everything great.

  • @annez8598
    @annez8598 6 років тому

    Many thanks! Look forward to your service worker crash course and many others!

  • @untakble
    @untakble 2 роки тому

    thank you very much I've been looking for this for a very long time

  • @akshitdandyan192
    @akshitdandyan192 3 роки тому

    Thanks Traversy Media, I will be using it in my MERN app

  • @nickythecasper4314
    @nickythecasper4314 2 роки тому

    very nice and simple frame for web push worker. Thanks a lot - I'm going to repeat on my project)

  • @chanakawijerathne8973
    @chanakawijerathne8973 4 роки тому +2

    Awsome Brad! You are my fav 👌 how can i impliment this push notification for a specific user?

  • @dimitargetsov9690
    @dimitargetsov9690 2 роки тому

    Great, as usual.....Sir Brad Traversy...

  • @jeremyc92
    @jeremyc92 6 років тому +1

    I couldn't get it to display the notification, but in the Service Workers section of Google Developer Tools I can see where it was received. Any ideas?

  • @hemantdubey313
    @hemantdubey313 6 років тому

    You are one of my biggest inspiration.

  • @paicolman
    @paicolman 2 роки тому +1

    This is really simple and cool, thanks a lot! One question thjough: I tried to modify the code to get notifications every 5 seconds by putting the webpush inside a setInterval... But the browser gets only one notification only. Would that even be possible?

  • @snehpanchal533
    @snehpanchal533 5 років тому

    superbly explained man , superb.

  • @joeg4609
    @joeg4609 Рік тому

    you’re a life saver, thanks a lot

  • @24mjohnson
    @24mjohnson 2 роки тому +2

    So how or where can you implement something that queries a database for specific tasks based on the user of that computer thats assigned to him in a database that is due at that time? Basically wanna have each person in a company that can run it and it runs every so many seconds or minutes and queries a database of whatever kind for tasks assigned to that user only and sends notification saying "you have X number of takss due at this time"?

  • @lickybuay
    @lickybuay 2 роки тому +1

    Nice tutorial, will be great if you can explain me how can i make this with user segmentation. For example i want to send a message to all the user that have to send required documents

  • @ColdStoneBoy
    @ColdStoneBoy 4 роки тому

    Great tutorial, easy to understand, thx!

  • @reubenjosephcabrera8179
    @reubenjosephcabrera8179 6 років тому +8

    do a pwa tutorial. thank you traversy

    • @TraversyMedia
      @TraversyMedia  6 років тому +4

      I plan on it, one of the things I am in the process of learning enough to teach :)

  • @chome4
    @chome4 4 роки тому +1

    How can you notify about a change to a specific website's content?

  • @Teedeewhyy
    @Teedeewhyy 6 років тому

    Bit late to the party, but could you please consider doing a video on how to actually send push notifications. For example, how to subscribe the user to a particular endpoint and post notifications to that endpoint/suggest a model for the system. I'm really struggling. Thanks.

  • @tuancharlie1
    @tuancharlie1 4 роки тому +1

    great impression of Woody Harrelson bro

  • @LouisNelZA
    @LouisNelZA 5 років тому

    This was really interesting and well executed. Subscribed!

    • @TraversyMedia
      @TraversyMedia  5 років тому

      Thanks man

    • @nicolasmorin9539
      @nicolasmorin9539 4 роки тому +2

      Why is does not work on safari ?

    • @sumanboi
      @sumanboi 3 роки тому

      @@TraversyMedia hey can i use this to send notifications even when the browser is closed...i mean running in the background

  • @wwhill8033
    @wwhill8033 6 років тому

    You provide fantastic videos, thanks!

  • @hazemhamada1436
    @hazemhamada1436 3 роки тому

    one of the best tutorials

  • @dwijvirani7919
    @dwijvirani7919 3 роки тому

    Great work and very well exlpained. Keep it up

  • @anishpr5658
    @anishpr5658 6 років тому

    Your tutorials are amazing :)

  • @MegaObka
    @MegaObka 6 років тому

    hey Brad
    why i love you and your video ? you are best

  • @maksimmamrikov3818
    @maksimmamrikov3818 4 роки тому +1

    Great video tutorial. I'm wondering why you decided to use the `web-push` library instead of the native `push api`? Also, what was your reason for building it on the server, instead of using the Notification API and building the functionality in the client?

    • @jww0007
      @jww0007 2 роки тому

      the server can decide what time to send any notification to any or many users

  • @ghanimalmarzouqi3277
    @ghanimalmarzouqi3277 6 років тому +3

    Thanks for the tutorial Brad. I'm just wondering if I can use this approach to show a notification in a mobile app. Say for example, a react native app or an android app.
    I need to learn more about Service Workers since they are new to me.
    Thanks again, greetings from Oman.

    • @compeng2013
      @compeng2013 5 років тому

      Did you ever get this figured out? I'm also trying to figure out if this would work with a React Native app

    • @RNMERIA
      @RNMERIA 5 років тому

      yes plz. can anyone point to a tutorial to do push notifications with FCM for react native ,android in a node app

  • @jawadhammoud9255
    @jawadhammoud9255 4 роки тому

    All ad networks have its pros and cons - concerning the outlook of ad formats, CPC, eCPM etc., and you have to test them in order to see if they work for you or not. At the moment, I use MonadPlug and its results are better than 99% of other ad networks..., and I would not know that if I did not test their network. Simple.

  • @raptordev2235
    @raptordev2235 6 років тому

    Thanks Brad this is very helpful

  • @Junyoung_Kang
    @Junyoung_Kang 5 років тому +1

    What... I am lost. I don't see any notification... ?

  • @tonniewhiteley2497
    @tonniewhiteley2497 6 років тому

    Love your videos , as always :) thanks for your help ))

  • @amirnoorani5017
    @amirnoorani5017 4 роки тому

    You are simply the best!

  • @БогданЮрчук-т8о
    @БогданЮрчук-т8о 6 років тому

    Brad, you make good videos. Thanks)

  • @vloggingkid4690
    @vloggingkid4690 6 років тому +1

    Great video man👍keep it up

  • @K8Tech
    @K8Tech 6 років тому

    Backend 😍.. thanks brad

  • @jamalabdullahi8155
    @jamalabdullahi8155 6 років тому +2

    Thanks my lecturer 👨‍🏫 I like you the most
    I request to go for deep service worker and caching the pages

    • @TraversyMedia
      @TraversyMedia  6 років тому +1

      Something i am definitely planning. I am in the process of digging into PWA

    • @jamalabdullahi8155
      @jamalabdullahi8155 6 років тому +1

      Many many thanks sir 🙏🏽🙏🏽🙏🏽🙏🏽🙏🏽🙏🏽👋👌🏽👏🏼

  • @faradniftaly8893
    @faradniftaly8893 4 роки тому

    This is awesome, keep up the good work, thx

  • @BarakaMahili
    @BarakaMahili 6 років тому

    This is dope Brad...thanks a bunch. How would you schedule for that push notification to be sent to your users... let's say every 90 days...(or every 2 minutes for testing purposes) even if they don't have your webpage opened? Thanks

  • @bizzle98
    @bizzle98 6 років тому

    Please... please do a playlist on creating a responsive wordpress theme *NOT A BUSINESS THEME* because that's all that's out there on youtube. Was hoping for a how to create a Newspaper magazine or a editorial/news theme from *SCRATCH* all tutorials out there are not actually coding it

  • @SethuSenthil
    @SethuSenthil 6 років тому

    This is a dream come true!

  • @TimurCatakli
    @TimurCatakli 6 років тому

    Thanks, very nicely explained...

  • @siddharathadhumale3683
    @siddharathadhumale3683 3 роки тому

    Very good explanation :)

  • @mrmupfukudzwa4374
    @mrmupfukudzwa4374 6 років тому

    Great tutorials as always

  • @hionut2718
    @hionut2718 6 років тому

    Awesome content! Do you know other cool channels like this?

  • @jegans3250
    @jegans3250 3 роки тому

    You really did it..🥰,
    Kindly update how can i send dynamic data in push notifications, in other server react js build🥺 please me

  • @carrillocarlosce
    @carrillocarlosce 6 років тому +8

    Thanks traversy

  • @daniellaerachannel
    @daniellaerachannel 6 років тому

    awesome Brad!

  • @petecapecod
    @petecapecod 6 років тому

    Edge and also Safari both just added service workers. So all major browsers now support them 👍😎

    • @meerbekakimzhanov6217
      @meerbekakimzhanov6217 2 роки тому

      You are talking about the version which will be on the next year?

    • @meerbekakimzhanov6217
      @meerbekakimzhanov6217 2 роки тому

      Please, help me it is not working for me

    • @petecapecod
      @petecapecod 2 роки тому

      This video was a couple years ago, you should have access to service workers in all major browsers.
      Sorry it's not working for you.

  • @DaveTradeFx_01
    @DaveTradeFx_01 4 роки тому

    That’s a good video, clear explanation and easy to understand…
    May I ask you, if I want to create a form input and send push notification to specific user, so what is the way or logic for the implementation with MERN stack, include redux as well? And one more thing, if we have multiple notification, do we create multiple custom-sw.js, right?
    Please give me some explanation and advice, appreciate your help :)

  • @alejandronahuelalaniz2793
    @alejandronahuelalaniz2793 5 років тому

    excellent video, it's works for me!

  • @konstantinkozokar7587
    @konstantinkozokar7587 3 роки тому

    Perfect video, I have one issue, push notifications doesnt appear on Android devices

  • @self_motivation_official
    @self_motivation_official 3 роки тому

    thank u so much ! have a good day

  • @ibraheemalsaady3216
    @ibraheemalsaady3216 6 років тому

    Hey Brad, big fan, great video.
    One question, if I want to push to the subscription from another endpoint/API, should I save the subscription into something like Redis or any kind of store?

  • @mujahidsanni1934
    @mujahidsanni1934 5 років тому +2

    I keep getting DOMException Error while registering push. I'd appreciate any help to solve this. Thanks a lot for the tutorial.

    • @JoeyLutes
      @JoeyLutes 4 роки тому

      i know it's a year old comment, but i had the same issue as well and corrected it by changing console.error to console.log

  • @bradbyrne3412
    @bradbyrne3412 3 роки тому

    Very Nice Thanks !!!! owe you a tip ... as soon as I can

  • @srikanthracharla420
    @srikanthracharla420 2 роки тому +1

    DOMException: Registration failed - no Service Worker, Getting this Error, while creating subscription object, anyone help me please

    • @TheDanDeeMan
      @TheDanDeeMan 2 роки тому

      Change to navigator.serviceWorker.register('./worker.js', {
      scope: '/'
      });

  • @nulI_dev
    @nulI_dev 6 років тому

    nice vid, would love to see an advanced wordpress udemy course

  • @max-rm1sk
    @max-rm1sk 6 років тому +1

    I wonder whether you can do the same thing for mobile app, android in specific?

  • @haaarshiiiit
    @haaarshiiiit 6 років тому +2

    Getting this error in the console after "Registering Push..." --
    [object DOMException]: {code: 20, message: "AbortError", name: "AbortError"}
    Any help would be greatly appreciated !

    • @95dannyboy
      @95dannyboy 5 років тому

      DOMException usually means something is blocked by the browser. Something like a sound, or a push notification. You can go to the settings of the browser to change it for certain domainnames. Say i.e. Chrome --> Go to 'Settings', then 'Advanced', then 'Settings for Content', then go to pop-up notifications and add the domain you want to give permission (i.e. localhost:5000) Hope this helps

  • @B0re_d
    @B0re_d 6 років тому

    Hi Traversy I'd like to know if you have some tips for beggining front-end developers basically I'm familiar with HTML5, CSS3 with all those transitions transformations etc and media queries, JS. What are some good excersises to progress in skill and make it let's say "easier" to build simple responsive websites eg one page layouts. I'm about to learn bootstrap and .Net but I still feel like a newbie lost in all that stuff. What would you suggest doing if you were me? Thanks for all the tutorials on this channel they helped me progress a lot. Keep up the good work!

  • @alessandroamedei810
    @alessandroamedei810 4 роки тому +1

    Thank you so much for the tutorial! I have a question, in this tutorial you subscribe to the server push notification system and you immediatly get a notification back: how can i subscribe the client, but send to him the notification throught another api call?

    • @mayank_upadhyay_19
      @mayank_upadhyay_19 4 роки тому +1

      I am also newbie, but I guess we need to save that subscription in database to send it notifications in the future.

  • @manushivammaheshwari946
    @manushivammaheshwari946 3 роки тому

    Notification is not popped up in my browser Chrome, in MacBook pro M1 chip. Even though I have active the notifications to allow and also have not set Do Not Disturb, Can you help me with this?

  • @akshatakhule9271
    @akshatakhule9271 6 років тому +1

    WebPushError: Received unexpected response code
    I am getting this error can u plz tell me what is it about?

  • @rajeev1668
    @rajeev1668 6 років тому

    Great tutorial .I really appreciate your efforts.
    Can also create video for advanced level of mongodb tutorial for complex schema design on Udemy.

  • @geek4001
    @geek4001 6 років тому

    Thanks brad.
    Brad, can you do a agenda, mongodb task job shefuler tutorial?

  • @kennymoreno5735
    @kennymoreno5735 6 років тому

    Thank you very much for these Tutorials, I would to know what are your thoughts regarding Web Assembly & AMP (accelerated Mobile Pages) it seems Google is pushing those techs for the future the same goes with the Flutter SDK - Thanks mate!.

  • @satyajeetkumarjha1482
    @satyajeetkumarjha1482 6 років тому +1

    Hey Brad .
    Will you come up with a react project based course ? I am learning from your mern stack course but I am looking for some project based react course to get a better understanding of framework.

    • @TraversyMedia
      @TraversyMedia  6 років тому +2

      satyajeet kumar jha about 85% sure that will be my next course

    • @satyajeetkumarjha1482
      @satyajeetkumarjha1482 6 років тому +1

      Traversy Media I will buy it the day u put it on udemy

  • @corsaronero5619
    @corsaronero5619 5 років тому

    Hi Brad very interesting video. when a crash course on PWA with push notification, camera and install on mobile, thanks Corsaro

  • @anasbenyaiche7653
    @anasbenyaiche7653 3 роки тому

    Clear !! Thank you

  • @freedom341
    @freedom341 6 років тому

    wowowowowo keep it up sir

  • @malikgenius4u
    @malikgenius4u 6 років тому

    i am a big fan of brad`s Udemy courses, one Suggestion, can we have one complete MERN course with Multer images / videos upload, service worker, push notification, nodemailer emails verification on users registration, new post alerts etc, i mean everything Brads have on youtube regarding Node.js and react in one complete course.. Please consider it for your next udemy course..

    • @TraversyMedia
      @TraversyMedia  6 років тому +1

      I have to think of timing and what you are talking about is a production level app. It is hard for me to come up with something that in depth in a sufficient amount of time and still be able to feed my family. I could maybe do something like that but it would be on the side of everything else I was doing so it would take a very long time and within that time technologies update and things would go out of date, which is very frustrating :(

    • @malikgenius4u
      @malikgenius4u 6 років тому

      Traversy Media oh yeah, i got ur point, maybe a second part of front to back mern can have those in seperate udemy course, where you start from where on top of existing project, really nobody want to see you doing it from scratch but an updater course of MERN, where all of us can subscribe to it as new course. just a thought...

  • @lindembergbarbosa6352
    @lindembergbarbosa6352 6 років тому

    awesome thanks for this tutorial.

  • @imaginarynoise
    @imaginarynoise 6 років тому

    Gettin' progressive up in here! Excellent choice!

  • @aishwaryabn2278
    @aishwaryabn2278 3 роки тому

    Hey worked fine in asking permission but in notifying part this is giving me an error that "I must pass in a subscription with at least an endpoint" how to fix it

  • @michelbouchet3605
    @michelbouchet3605 6 років тому

    I followed your nice video tutorial and thanks to it have now something working locally.
    I would like to go for the next step and make something working on the server (for example on Heroku). Do you have any tip for that?