Published on December 14, 2016 by Chrome

Read the Firebase Cloud Messaging documentation: goo.gl/h3wBld

One of the coolest features to land in Chrome recently is the ability to send a user a push notification. These notifications may trigger in response to a user action or could just be used as a mechanism to notify the user when you launch some new content. Traditionally setting up push notifications has required a fair bit of JavaScript and Service Worker know-how. Thanks to polymerfire’s firebase-messaging element we can greatly simplify the process. Check out today’s episode as we cover the basics of setting up firebase-messaging and dispatching our first notification using CURL.

Sample Code
github.com/polymer/polycasts

Firebase Messaging on beta.webcomponents.org:
beta.webcomponents.org/element/firebase/polymerfire/firebase-messaging

Polycasts playlist: goo.gl/r5fsMq
Polymer Slack: bit.ly/polymerslack
Polymer G+: goo.gl/YC5Bsh

Subscribe to the Chrome Developers channel: goo.gl/OUF4e2

Leave a Reply

41 Comments on "Firebase Messaging — Polycasts #59"

Notify of
avatar

Dean Martin
Guest
Dean Martin
1 day 7 hours ago

Does this work when the browser is not open at all? Like native push?

Tevin Thuku
Guest
Tevin Thuku
2 months 5 days ago

Thanks Rob For this tutorials. They are amazing 🙂

phani1 kumar
Guest
phani1 kumar
2 months 9 days ago

Thank you Rob for all the great tutorials. How do we let the users unsubscribe from the messaging? ` this.$.userToken.destroy();` inside the else block of `toggleSubscription` doesn't work! I couldn't find any documentation of `firebase-messaging` that tells us how unsubscribe can be performed. Though the above statement deletes record from database, when the user refreshes page, it automatically subscribes without even asking the user whether they want to subscribe or not!Edit: Even after removing the service-worker registered, somehow the browser refresh brings back the subscription token kind of magically! I seriously need a way to unsubscribe.

phani1 kumar
Guest
phani1 kumar
1 month 8 days ago

Nope! my issue that I raised in github is left unanswered. github.com/firebase/polymerfire/issues/182

Slak Tary
Guest
Slak Tary
1 month 8 days ago

did you manage to find a solution ?

Denis TRUFFAUT
Guest
Denis TRUFFAUT
3 months 17 days ago

@rob_dodson I'm not able to get the token after clicking yes on the notification approval, in my code or with yours. I use the polymerfire v0.10.3

Suyash Bansal
Guest
Suyash Bansal
4 months 8 hours ago
I was trying the messaging feature described above. I am having 2 problems, one is that there is no token value saved in the firebase when I allow notifications in the browser & second is that I am not able to do curl. I am running Win10 and it gives this error:curl: (6) Could not resolve host: dgMc9xNHmHccurl: (6) Could not resolve host: notificationcurl: (3) [globbing] unmatched brace in column 1curl: (6) Could not resolve host: Hello World,curl: (6) Could not resolve host: bodycurl: (3) [globbing] unmatched close brace/bracket in column 23JSON_PARSING_ERROR: Unexpected character (') at position 0.What can I… Read more »
GuateDev IO
Guest
GuateDev IO
3 months 12 days ago

It seems the issue is caused by the single quote. For windows try not to use single quotes, and escape any double quotes within the string. This example work for me: >>>>>> curl –header "Authorization: key=AAAA2aC_hss:APA91bHcFtbc0-1AqA5jSwHiTITx2YD4M00M63YzH91TxxSGtr1r8ph9MxQ61rm5gAk_eo10of1_jLw3pMpCB6qs0aZEguNqlU5yaZ-iuCdiD602M_rCc5VXkWAUmmifDdF7rvpO0Wt_U2tEPhkcMkj6ssdORgYRgw" –header "Content-Type: application/json" -d "{"to": "eD2TN30-pLI:APA91bGaUSNcPmWGDMRy-be5Y6bjRwgUT51dCCdrBfj-63_BtVWdsx61Vce7DR_bb6c2ZImV0kEft35n3pNZ3xCr0x50cLv-2T_aR-VxNprxZ62KBh9EY0lDnNyr4TwfOTHUcf0z_gbn", "notification": {"title": "Hello World", "body": "This is a notification"}}" fcm.googleapis.com/fcm/send

Brad Walters
Guest
Brad Walters
4 months 1 day ago

:-):-)

Kevin Weekes
Guest
Kevin Weekes
4 months 2 days ago

#AskPolymer Will there be significant changes to building production-ready Firebase/Polymer apps when Polymer 2.0 is released?

Tony Trinh
Guest
Tony Trinh
4 months 2 days ago

11:2611:31 That's me all day 😉

Michael Fons
Guest
Michael Fons
4 months 4 days ago

amazing! thank you Rob!!!

Eric Diaz
Guest
Eric Diaz
4 months 4 days ago

Thanks a bunch for another very helpful polymer firebase tutorial!I learned a bunch from this one that I really had no idea about despite fiddling around with polymerfire for a couple months. In particular thank you for touching on the point of when to use query vs document! :)I know that it's a lot of work to make these videos and they have to be focused. In the future, I would love to see a real example of seeing up the message send and also how to do the toast you mentioned.Thanks Rob!

1 2 3
wpDiscuz