Skip to content

Push notifications

The push channel delivers alerts to the Android app through Firebase Cloud Messaging.

  1. Create a Firebase project and enable Cloud Messaging.

  2. Create a service account with permission to send messages, and download its JSON key.

  3. Give the whole file to Watcher, verbatim, as a single environment variable:

    .env
    FIREBASE_SERVICE_ACCOUNT_JSON={"type":"service_account","project_id":"...","client_email":"...","private_key":"..."}
  4. Build and install the Android app, point it at your instance, and sign in. The app registers its device token automatically.

  5. Add push to a watch’s channels and force a run to test.

  • An alert fans out to every device token registered to the watch’s owner.
  • Delivery counts as successful if at least one device accepted it.
  • Tokens the provider reports as gone (uninstalled app, rotated token) are pruned automatically.
  • Messages are data-only: the app renders the notification itself, so device-side preferences — which tiers to show, quiet hours — are honoured even when the app is closed.

Watcher mints its own short-lived access token from the service account using standard cryptography; there is no Firebase SDK dependency on the server.

The app handles this, but the routes are open to any client:

Terminal window
curl -s -X PUT "https://<your-host>/devices/<token>" \
-H "authorization: Bearer $TOKEN" \
-H 'content-type: application/json' -d '{"platform":"android"}'

See Devices API.

Android only. The iOS project in the repository is unmaintained, and the device platform field currently accepts android alone.

  • The service-account JSON is a credential: it can send messages as your project. Keep it in the environment or a secret store.
  • Watcher never logs it, and its errors report status codes only — never the key material or the device token.
  • Registration tokens are device addresses, not secrets, but they are still scoped per owner and never returned to other accounts.