Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Web Push Notification with FCM

Avatar for Himadri Himadri
December 08, 2017

Web Push Notification with FCM

Talking about Web Push Notification with Firebase Cloud Messaging services at ReactJs Bangalore Meetup on 9th December 2017.

Avatar for Himadri

Himadri

December 08, 2017
Tweet

Other Decks in Technology

Transcript

  1. 8% increase in conversion rates on recovered carts. 600K+ users

    have signed up since November 2016 9X more conversion on previously abandoned carts. 178% increase in conversion vs. mSite users who do not receive notifications. 50% increase in repeat visits within 3 months Source: Google Case Studies
  2. • Create a firebase project in Firebase console (We can

    also import from existing Google project) • Click on Add Firebase to your web app.
  3. manifest.json NOTE - This value is common for every FCM

    javascript client, not project specific
  4. Service worker for receiving messages: NOTE - By default, firebase

    messaging service worker in firebase-messaging-sw.js
  5. FCM Web Page App Server register() ServiceWorkerRegistration messaging.useServiceWorker(swReg) messaging.getToken() subscription

    token User Agent (Firebase SDK) messaging.requestPermission() Promise (resolve, reject) token updateTokenToAppServer(token) onTokenRefresh()
  6. Two types of messages: ❏ Notification message • Set of

    predefined keys • Optional data payload • FCM SDK handles automatically
  7. Two types of messages: ❏ Notification message ❏ Data message

    • Set of predefined keys • Optional data payload • FCM SDK handles automatically • Client app needs to be handle. • Custom key-value pairs NOTE - If we specify notification field, it will take precedence over any values in SW.
  8. FCM Web Page App Server User Agent (Firebase SDK) Service

    Worker message message event notification event
  9. • Browsers must provide service worker support. • FCM SDK

    supports only in HTTPS served pages, due to service worker. • Sending message from Firebase console.
  10. • Ask permission carefully. • Use icon with a relevant

    image. • Title should be precise form of the information. • Don’t use domain name in title or body. • Click action navigation should based on notification information.