Developer docs

11. Push notifications for third-party clients

On this page

APNs and FCM only accept pushes from whoever holds the app’s own credentials, so the Telvoro server cannot push directly to a third-party app. Third-party clients therefore use one of:

KindWho holds credentialsUse for
KIND_WEBPUSHnobody (RFC 8030 + RFC 8291 encryption + VAPID)browsers, desktop
KIND_UNIFIEDPUSHthe user’s distributor (e.g. ntfy)de-Googled Android
KIND_GATEWAYthe client developer, in their own push gatewayiOS / Android third-party apps

Gateway flow (RegisterPushToken{kind: KIND_GATEWAY, token: <APNs/FCM token>, app_id, gateway_url, encryption_key}):

POST <gateway_url>           Content-Type: application/json
{
  "app_id":   "com.example.client",
  "pushkey":  "<token as registered>",
  "type":     "message" | "call" | "revoke",
  "priority": "high" | "normal",
  "collapse_key": "<chat_id>",
  "payload":  "<base64: AES-256-GCM(encryption_key, nonce||ciphertext) of a serialized PushPayload>"
}
→ 200 {"rejected": false}      or  {"rejected": true}  (token dead: server deletes it)

The gateway forwards payload untouched to APNs/FCM (iOS: as a mutable-content alert so the Notification Service Extension decrypts it). The gateway never sees message content, chat titles or the session token. Requirements enforced by the server: https only, public IPs only (no private/loopback/link-local, re-checked after DNS resolution), 5 s timeout, per-gateway rate limit, retries with backoff for 5xx only.

Payload encoding (exact). payload = standard base64 (RFC 4648 §4, padded) of nonce(12 bytes) || ciphertext || tag(16 bytes), where the ciphertext is AES-256-GCM under the 32-byte encryption_key registered with the token, with a fresh random 96-bit nonce and no associated data. The plaintext is a serialized televo.v1.PushPayload (users.proto):

fieldmeaning
typemessage, call, secret (secret-chat item queued: fetch with SecretService/GetQueue) or revoke (session logged out: wipe local data)
chat_id, message_id, ptswhat to fetch / where to deep-link
sender_id, call_id, videocaller / sender
title, bodypreview (chat or sender name; text truncated to 200 chars, media as a label such as “📷 Photo”)
badgetotal unread in non-muted private chats and groups; -1 = leave unchanged (channels)
silentdeliver without sound
sound, hidden_previewthe tone ("", none, b:<tone>, c:<id><.ext>) and “previews off” (§23)

KIND_GATEWAY registrations without a 32-byte encryption_key are rejected (ENCRYPTION_KEY_REQUIRED). The top-level JSON type is always one of message | call | revoke: a secret payload travels as type: "message". Reference decryptor: server/internal/push.OpenPayload.

11.1 Push encryption: exact formats (normative)

There are two encrypted push formats. Both use AES-256-GCM, a 32-byte key (RegisterPushToken.encryption_key, generated per device), a fresh random 12-byte nonce for every push, and a 16-byte tag.

Direct providers (APNs / FCM / Web Push / UnifiedPush)Third-party gateway (KIND_GATEWAY)
Wherefield e of the flat string map (other fields: t, chat_id, msg_id, pts, from, call_id as decimal strings)JSON field payload
Bytesnonce(12) ‖ ciphertext ‖ tag(16)nonce(12) ‖ ciphertext ‖ tag(16)
Encodingbase64url, no padding (RFC 4648 §5)standard base64, padded (RFC 4648 §4)
AADASCII televo-push-v1none
PlaintextUTF-8 JSON, keys sorted, no whitespace: {"body","chat_id","from","msg_id","title"}. Ids are JSON numbers; body is truncated to 200 characters, media as a label like “📷 Photo”serialized televo.v1.PushPayload (protobuf)
Present whenthe device registered a key and the push has a previewalways (a key is mandatory)

Note: iOS Data(base64Encoded:) accepts only standard base64. Translate -→+ and _→/ and re-pad before decoding e.

Test vector (key = bytes 0x00…0x1f, nonce = 0xa0…0xab; notification: message 9 in chat 5 from user 7, title “Ann”, body “hi”, badge 3):

e plaintext:   {"body":"hi","chat_id":5,"from":7,"msg_id":9,"title":"Ann"}
e:             oKGio6SlpqeoqaqrnToeQiGyIIVADe7xK1ijthHYBnn2lXhZsCxA9BDGVzvlWmWS3EUMVDu-PvElWPeQM3cjaljyWxAvfHbHDxrR600tOIe75c4Clxd3
PushPayload:   0a076d6573736167651005180928073a03416e6e420268694803   (hex; type=message chat_id=5 message_id=9 sender_id=7 title=Ann body=hi badge=3)
gateway:       oKGio6Slpqeoqaqr7B8RSDa4Y9gHdYLLDlLH5HPtN37QtSoF1A13EbmromOaGiI5QHAr7wRJ

These are pinned by server/internal/push/vector_test.go and verified independently with WebCrypto.

Generated from docs/PROTOCOL.md in the Telvoro repository. Wire names such as televo.v1 are unchanged.