Skip to main content

Video Chat Firebase Schema

Use this page when your app includes video chat through WebRTC signaling or a call module that stores call metadata in Firebase.

Quick Answer

Firebase is used for identity, call state, signaling, notification tokens, and cleanup metadata. Media does not flow through Firestore. WebRTC media flows peer-to-peer or through TURN/Twilio depending on your implementation.

Common Data Areas

Exact collection names can differ by app, so search your source code for the actual names before editing rules or seed data:

rg "pushKitToken|fcmToken|audioVideo|callId|callStatus|offer|answer|candidate|incomingCall" src firebase

Typical data includes:

DataPurpose
User FCM tokenStandard push notification delivery.
User PushKit tokeniOS VoIP call delivery.
Active call stateTracks caller, recipient, call type, status, and timestamps.
WebRTC offer/answerSignaling payloads exchanged before a WebRTC session starts.
ICE candidatesNetwork negotiation data for WebRTC connectivity.
Call logsOptional history for missed, declined, accepted, or ended calls.

Security Rules Checklist

Before production:

  • users can only read call documents where they are participants;
  • users can only create calls from their own user ID;
  • users cannot spoof another participant;
  • signaling documents are scoped to a call;
  • old signaling documents are cleaned up;
  • user tokens are writable only by the signed-in user or trusted backend;
  • call logs do not expose private metadata to unrelated users.

Cost Controls

Call signaling can create many short-lived writes. Keep costs controlled by:

  • deleting old call state after calls end;
  • limiting listeners to active calls only;
  • avoiding global listeners over all calls;
  • storing only metadata needed for the call flow;
  • moving high-volume cleanup to Cloud Functions when needed.

Next Steps