Skip to content

Use Firebase Cloud Messaging to generate browser notifications from a command line

License

Notifications You must be signed in to change notification settings

drinckes/push-notifications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Push Messages To Browser Notifications

This repository provides a linux command that uses Firebase Cloud Messaging to forward a message to a browser and generate a browser notification.

This can be used when working on a terminal window running commands, to find out when those commands have completed.

Usage

Send the default message:

./sendmsg.sh

Change the title and body:

./sendmsg.sh -b "new notification body" everything left over is the title

Run in a pipeline, sending a message after the previous command completes with the last 2.5k of the output:

find / --name core | sendmsg.sh -t

Or the first 2.5k of the output:

find / --name core | sendmsg.sh -h

If the message token changes:

./sendmsg.sh -t <MESSAGE TOKEN> Updating message token

Configuring

  1. Go to firebase.google.com and create a project.
  2. Open the Firebase project settings (gear icon at top left).
  3. Switch to the Cloud Messaging tab and copy the server key to a text editor, you'll need it when you first run the sendmsg.sh script.
  4. In the Web configuration panel, highlight Web Push certificates and press Generate key pair. Copy this into web/project-config.js as webPushCertificateKey.
  5. Switch to the General tab and add a web app. (If you don't have an HTTPS site to host your files on, set up Firebase hosting.)
  6. Copy the Firebase configuration (starting with const firebaseConfig) to web/project-config.js.
  7. Update web/project-config.js with the full URL to the file messaging.html.
  8. Upload the files in web to your HTTP server or deploy them to Firebase hosting.
  9. Open messaging.html in a browser. It should ask your permission to show notifications (grant it), and then display a message token.

Run:

./sendmsg.sh -s <SERVER KEY> -t <MESSAGE TOKEN> Setting key and token

You should get a browser notification!

Code

Code is checked using the superlinter GitHub action, and formatted using standard.

About

Use Firebase Cloud Messaging to generate browser notifications from a command line

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published