nuntius

command module
v0.0.0-...-be128b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

README

nuntius

nuntius is a command line tool for sending Firebase push notifications to Android devices, iOS devices, and browsers (web push notifications). "nuntius" is the Latin word for messenger. I don't explain here how to enable your devices to receive push notificaitons. Google has tutorials on that here: Android, iOS, and Web. However, once you do have your device enabled to receive notifications, sending notifications is fairly easy with nuntius. First get your credentials file from Firebase. ./nuntius -help explains how:

  -credentialsFile string
    	A Firebase credentials file downloaded from the Firebase console.
    	Log into the Firebase console and go to your project. 
    	Beside "Project Overview" on the left click the gear/settings icon.  
    	Select "Project Settings".  In the Project Settings page, click on "Service accounts".  
    	Scroll down and click on "Generate new private key".  This is your credentials file.

After you have your credentials file, create a message file in this format (again explained by ./nuntius -help):

  -pushFile string
    	A file that contains a notification (title, body, image (optional)) 
    	and/or data (a map of key/value pairs) that will be pushed to the client(s). 
    	Format:
    	{
    	   "notification" : { 
    	      "title" : "Test Title",
    	      "body"  : "Test Body",
    	      "image" : "https://whatever.com/image.png"
    	   },  
    	
    	   "data" : { 
    	     "key1" : "value1",
    	     "key2" : "value2"
    	   }   
    	}

Finally, you'll need either the Firebase token for your device or the topic channel that your device is subscribed to.
The easiest way to get your device token is to log it when the device registers with Firebase. You then send a push notifications like this (token) :

./nuntius -credentialsFile=firebaseProjectCreds.json -pushFile=someMessageFile.json -token=fYYY08QjXXXXX91bFXm9hKq3VjXXXXXBGqAWZQfa6aZYYYYYSoX8-Qrho7nqI1KTtRdOMXXXXXXXXXXXIo0MqwLP8b2FjugpTe07bT3wm5DgXXxUux-

or this (topic):

./nuntius -credentialsFile=fireaseProjectCreds.json -pushFile=someMessageFile.json -topic=myClientsSubscribedTopic
You can get it here

You can download the Ubuntu version here (built on Ubuntu 18.04LTS), the Mac version here (built on macOS Mojave), and the Windows version here These are all standalone executables. You don't need to install any libraries to run them, but on Linux/Mac you'll need to

chmod +x nuntius

to make them executable.

Or you can build it yourself

If you want to build nuntius yourself, you'll need to install Go. Many sites give instructions on this so I won't repeat them. Here's a good one: How to Install Go on Ubuntu 18.04. Once Go is installed, you can build it by simply typing:

    /home/ubuntu> git clone https://github.com/metaphyze/nuntius.git
    /home/ubuntu> cd nuntius
    /home/ubuntu> go build nuntius.go
Command line options

Here's the complete list of command line options.

  -help 
      Print out all the options
  -credentialsFile string
    	A Firebase credentials file downloaded from the Firebase console.
    	Log into the Firebase console and go to your project. 
    	Beside "Project Overview" on the left click the gear/settings icon.  
    	Select "Project Settings".  In the Project Settings page, click on "Service accounts".  
    	Scroll down and click on "Generate new private key".  This is your credentials file.
  -pushFile string
    	A file that contains a notification (title, body, image (optional)) 
    	and/or data (a map of key/value pairs) that will be pushed to the client(s). 
    	Format:
    	{
    	   "notification" : { 
    	      "title" : "Test Title",
    	      "body"  : "Test Body",
    	      "image" : "https://whatever.com/image.png"
    	   },  
    	
    	   "data" : { 
    	     "key1" : "value1",
    	     "key2" : "value2"
    	   }   
    	}
  -token string
    	token to send the message to
  -topic string
    	topic to send the message to
  -ttl int
    	Time-to-live value for notifications in seconds.
    	0 (default) means "now or never", that is,
    	deliver the message now or don't deliver it at all.
    	Max value is 2419200 (28 days).
    	For details see: https://firebase.google.com/docs/cloud-messaging/concept-options

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL