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

38 Comments on "Firebase Messaging — Polycasts #59"

Notify of
avatar

Tevin Thuku
Guest
Tevin Thuku
4 days 5 hours ago

Thanks Rob For this tutorials. They are amazing 🙂

phani1 kumar
Guest
phani1 kumar
7 days 22 hours 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.

Denis TRUFFAUT
Guest
Denis TRUFFAUT
1 month 16 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
1 month 30 days 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
1 month 11 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
2 months 9 hours ago

:-):-)

Kevin Weekes
Guest
Kevin Weekes
2 months 1 day 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
2 months 1 day ago

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

Michael Fons
Guest
Michael Fons
2 months 2 days ago

amazing! thank you Rob!!!

Eric Diaz
Guest
Eric Diaz
2 months 3 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!

Ario Artins
Guest
Ario Artins
2 months 7 days ago

Am sorry, to take you aback but would like to know if I can do polymer without learning javascript or which parts of javascript that are required. I would like to take on polymer as soon as possible but javascript is prooving to be lengthy to me.Thanx

julie lopez
Guest
julie lopez
1 month 24 days ago

Ario Artins iklkhjloijhklll

Ario Artins
Guest
Ario Artins
1 month 27 days ago

Thanx Mr.Rob

Rob Dodson
Guest
Rob Dodson
2 months 5 days ago

You will need to learn JavaScript to work with Polymer

1 2 3
wpDiscuz