Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

772 B
Raw Blame
import { apiJson } from './client'

export type PushPlatform = 'ios' | 'android'

// Needs `user:write`. The server upserts on (user, token), so a call on every launch only refreshes `last_seen_at`.
export async function registerPushToken(
    token: string,
    platform: PushPlatform,
    init: { signal?: AbortSignal } = {}
): Promise<void> {
    await apiJson('/api/users/@me/push_tokens/', { method: 'POST', json: { token, platform }, ...init })
}

/** Removes the token for the signed-in user. The server returns 204 even when nothing matched. */
export async function unregisterPushToken(token: string, init: { signal?: AbortSignal } = {}): Promise<void> {
    await apiJson('/api/users/@me/push_tokens/unregister/', { method: 'POST', json: { token }, ...init })
}