POST /v1/events) and the RabbitMQ consumer.
The notification event: one schema shared by the REST API
(POST /v1/events) and the RabbitMQ consumer.
{
"id": "optional correlation id (generated when absent)",
"type": "notification" | "data" | "voip", default notification
"user_ids": ["alice", "bob"], recipients, resolved via the token store
"user_id": "alice", shorthand for a single recipient
"tokens": [{"token": "...", "provider": "fcm" | "apns_voip",
"platform": "ios" | "android" | "web" | "unknown"}],
"notification": {"title": "...", "body": "...", "image": "https://...",
"sound": "default", "badge": 3},
"data": {"any": "key/value pairs"},
"priority": "high" | "normal", default high
"ttl": 3600, seconds; default 0 for voip, unset otherwise
"collapse_key": "optional",
"providers": ["fcm", "apns_voip"], restrict which providers are used
"exclude_device_ids": ["..."] skip these devices (token store only)
}
At least one of user_ids/user_id/tokens is required.
type:
notification — a visible alert, sent through FCM (which also
delivers to iOS via its APNs bridge). Needs a title or a body.data — a silent, data-only push through FCM (background
content-available push on iOS).voip — an incoming-call push: an APNs PushKit push to every
apns_voip token, plus a high-priority data-only FCM message to
every fcm token (how Android apps ring).parse/1 validates and normalises the decoded JSON into the
internal event() map with atom keys; it never crashes on bad input.
event() = #{id := binary(), type := event_type(), user_ids := [binary()], tokens := [target()], notification := map(), data := map(), priority := high | normal, ttl := non_neg_integer() | undefined, collapse_key := binary() | undefined, providers := [provider()], exclude_device_ids := [binary()]}
event_type() = notification | data | voip
provider() = fcm | apns_voip
target() = #{token := binary(), provider := provider(), platform := binary(), device_id => binary() | undefined}
| allowed_providers/1 | Providers an event of this type may use when none are given. |
| new_id/0 | A random 128-bit hex correlation id. |
| parse/1 | Validate and normalise a decoded JSON object. |
allowed_providers(X1::event_type()) -> [provider()]
Providers an event of this type may use when none are given.
new_id() -> binary()
A random 128-bit hex correlation id.
parse(Json::term()) -> {ok, event()} | {error, binary()}
Validate and normalise a decoded JSON object.
Generated by EDoc