Coder Social home page Coder Social logo

abnirhencazs / electron-fcm-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cydeswype/electron-fcm-demo

0.0 0.0 0.0 9 KB

Example app demonstrating Firebase Cloud Messaging push messages to Electron desktop app

License: Creative Commons Zero v1.0 Universal

HTML 12.68% JavaScript 87.32%

electron-fcm-demo's Introduction

electron-fcm-demo

Demonstration of electron-push-receiver. This demo app shows how to make use of Matthieu Lemoine's excellent electron module for receiveing push notifications from Google's Firebase Cloud Messaging (FCM) service.

# Clone this repository
git clone https://github.com/CydeSwype/electron-fcm-demo
# Go into the repository
cd electron-fcm-demo
# Install dependencies
npm install

You'll need a free Firebase project and you'll want to have Postman installed to simulate the server push.

  1. Go to the Firebase starting page
  2. Select (or create a new) project
  3. Go into your Firebase project settings and then into Cloud Messaging
  4. Copy your Sender ID and paste it into renderer.js (in place of 123456789)
  5. Also copy your Server Key and replace the placeholder value of "SERVER_KEY" in the postman_collection.json
# Run the app
npm start

With the app running, select View -> Toggle Developer Tools. You should see the client's FCM push token in the Chromium debug console. Copy this token and paste it into the postman_collection.json (replacing "FCM_CLIENT_PUSH_TOKEN" with it). You should now be able to send yourself (or any other client registered with your Sender ID) a push message using Postman.

This example shows how you can make use of a "silent push message" by not providing the optional body of the message. This is an arbitrary design and you could just as easily use a flag in the data portion of the push payload to determine whether the user should see a notification vs. it being silent. Silent pushes can be useful for informing clients of new information only when changes occur on your server without having all clients query your servers at regular intervals (creating unnecessary load even when there may be no new information for them).

Note: There is a feature in FCM's web console that allows you to send single or batch push notifications ad-hoc. This feature seems to only be functional for iOS and Android clients. At the time of this writing, it doesn't appear that the web console allows for sending to desktop/JS clients.

License

CC0 1.0 (Public Domain)

electron-fcm-demo's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.