Need to send push notifications to your mobile or web clients β from the command line, a backend script, or a CI/CD pipeline β without building a full backend server?
Notifycli is a simple, Go-based CLI that does exactly that: use Firebase Cloud Messaging (FCM) credentials + a device token to send push notifications.
In this post, I unpack the code, show installation and usage, and highlight how it's built β so you can use or extend it for your own projects.
What is Notifycli?
According to the project README:
- Notifycli is a βGo CLI for sending push notifications to mobile and web devices using Firebase Cloud Messaging.β (GitHub)
- It supports sending to a single device (via FCM device token), and allows custom data payloads β e.g. a title, body, optional URL β which your app can use for deep linking or redirection. (GitHub)
- It uses a clean project structure based on the popular CLI framework Cobra for subcommands and flag parsing. (GitHub)
Because it's a standalone binary (no heavy deps, no web server), it works well for automation: cron jobs, server scripts, deployment hooks, or any backend that just needs to βfire-and-forgetβ an FCM push.
Project Structure & Architecture
Hereβs how the repo is structured: (GitHub)
Notifycli/
βββ cmd/
β βββ root.go # CLI root command definitions
β βββ notify.go # βnotifyβ subcommand: sends a notification
βββ internal/
β βββ firebase/
β βββ client.go # Firebase FCM client wrapper
βββ main.go # Entry point
βββ go.mod / go.sum # Module definitions
βββ test/ # (optional) tests
βββ README.md
Highlights:
-
cmd/: Uses Cobra to define commands and flags. -
internal/firebase/client.go: Encapsulates FCM initialization, authentication using a Firebase service-account JSON key, and the logic to send notifications via FCM REST API. (GitHub) - Minimal external dependencies β this keeps the binary lightweight and portable.
- Easy to integrate with scripts, cron jobs, CI/CD pipelines β you just call
notifcli notify ....
How to Build & Use
1. Clone & Build
git clone https://github.com/johnafariogun/Notifycli.git
cd Notifycli
go build -o notifcli
# optionally:
go install
2. Provide Firebase Credentials
- Go to your Firebase project β Project Settings β Service Accounts β Generate new private key.
- Download the
serviceAccount.jsonand place it in your project root (or anywhere you like, but pass its path with--creds). (GitHub)
3. Send a Notification via CLI
notifcli notify \
--token <DEVICE_FCM_TOKEN> \
--title "Deployment Successful" \
--body "Your service is live." \
--creds /path/to/serviceAccount.json
Optional flag: --url, to include a link in the data payload (useful for app deep links or redirect URLs). (GitHub)
Thatβs all β a simple, one-liner to trigger a push notification from anywhere.
Under the Hood: Whatβs Going On
- The CLI parses flags (token, title, body, url, creds) via Cobra in
cmd/notify.go. (GitHub) - The
internal/firebase/client.gomodule: initializes a Firebase app using the provided service account, constructs the FCM message (with title/body, and optional data payload containinglink), and sends the request to FCM via HTTPS. (GitHub) - Error handling covers cases like missing credentials, invalid FCM token, or network failures. The CLI prints descriptive error messages. (GitHub)
- Because it's a native Go binary, itβs cross-platform (Linux, macOS, etc.) and doesnβt require runtime dependencies beyond Goβs standard library + net/http.
Why This Tool Matters
- Simplicity & Speed: No need to build a full backend just to send notifications.
- Automation-friendly: Great for deployment scripts, CI/CD, cron jobs, or server-side alerts.
- Portable: Build once, deploy anywhere.
-
Extensible: You can extend
internal/firebase/client.goto support more advanced FCM features β e.g. topic messages, batch sends, custom data payloads, image notifications. The architecture is clean and modular. (GitHub)
Wrap-up & Final Thoughts
Notifycli is a great example of how a small, focused tool can do one thing well β in this case: send FCM push notifications β and integrate easily into scripts, automation, or backend workflows.
Its clean Go + Cobra structure and minimal dependencies make it perfect for developers or DevOps workflows that donβt need a full backend server just for notifications.
If you need a lightweight, scriptable, cross-platform tool for mobile/web push notifications β especially useful for deployment alerts, status updates, or automation β give Notifycli a try.
Top comments (0)