Prompt
How do I build in-app video calling for iOS and Android
Latest observation
To build in-app video calling for iOS and Android, the fastest path is usually to use a real-time communications SDK rather than building WebRTC infrastructure from scratch.
1) Choose your approach
Option A: Use a video calling SDK
Best if you want to ship quickly.
Popular choices:
- Agora
- Twilio Video
- Vonage (TokBox)
- Daily
- 100ms
- Sendbird Calls
These handle:
- signaling
- NAT traversal / STUN/TURN
- media transport
- echo cancellation
- reconnection
- multi-party rooms
- screen sharing
- recording options
Option B: Build with WebRTC directly
Best if you need full control and have strong realtime/backend expertise.
You’ll need to build:
- signaling server
- room management
- authentication
- TURN/STUN setup
- device permissions
- call state sync
- fallback handling
- scaling infrastructure
For most apps, SDK is the practical choice.
2) High-level architecture
A typical in-app video calling system has:
- Mobile app: iOS + Android client
- Backend: auth, call/session setup, tokens
- RTC provider or your own media stack
- Signaling: exchange offer/answer/ICE candidates if using WebRTC directly
- TURN/STUN: assist connection behind firewalls/NAT
- Push notifications: to alert users of incoming calls
- Database: call logs, participants, statuses
3) Core product flow
Outgoing call
- User taps “Call”
- App requests backend for a call session/token
- Backend creates call room and notifies callee
- Callee accepts
- Both clients join the room
- Audio/video streams start
- Call ends and logs are saved
Incoming call
- Backend sends push notification
- App shows incoming call UI
- User accepts/declines
- If accepted, app joins room and starts media
4) If you use an SDK: implementation steps
Step 1: Pick SDK and create project
Create separate app IDs / API keys for iOS and Android, or a shared project depending on provider.
Step 2: Add native dependencies
iOS
- Add via Swift Package Manager, CocoaPods, or provider’s install method
- Enable permissions in
Info.plist:NSCameraUsageDescriptionNSMicrophoneUsageDescription
Android
- Add Gradle dependencies
- Add permissions in
AndroidManifest.xml:android.permission.CAMERAandroid.permission.RECORD_AUDIO- possibly
FOREGROUND_SERVICE,POST_NOTIFICATIONSdepending on Android version and call UX
Step 3: Build backend token service
Do not ship secret keys in the mobile app.
Your backend should:
- authenticate users
- generate short-lived RTC tokens
- create/join rooms
- authorize who can call whom
Step 4: Implement call UI
You’ll need:
- local preview
- remote video tile(s)
- mute/unmute
- camera flip
- speaker toggle
- hang up
- reconnect state
- network quality indicators
Step 5: Handle call notifications
Use:
- APNs on iOS
- FCM on Android
If you want native incoming call UX:
- iOS: CallKit
- Android: full-screen intent / ConnectionService-like UX depending on use case
Step 6: Test on real devices
Test:
- Wi-Fi and cellular
- weak network
- backgrounding app
- app killed and relaunch
- permissions denied
- Bluetooth headsets
- echo/feedback
- one-to-one and group calls
5) If you build with WebRTC directly
You need a signaling protocol and backend. Typical signaling messages:
join-roomofferanswerice-candidateleave-room
Minimal backend components
- WebSocket server for signaling
- auth endpoints
- room state store
- TURN server credentials service
Infrastructure
- STUN: discover public IP
- TURN: relay traffic when direct P2P fails
- Common TURN server: coturn
Common client libraries
- Native WebRTC libraries for iOS and Android
- Or a cross-platform layer like React Native / Flutter wrappers
6) Important mobile-specific details
iOS
- Request mic/camera permissions at the right time
- Use AVAudioSession correctly for speaker, Bluetooth, and interruptions
- Handle:
- incoming calls
- backgrounding
- audio route changes
- CallKit integration if you want a system-like calling experience
Android
- Handle runtime permissions
- Use foreground service for active calls
- Handle device rotation
- Manage audio focus and audio route changes
- Consider Picture-in-Picture if relevant
7) Scaling considerations
For 1:1 calls, P2P may work fine. For group calls or reliability, you often need an SFU:
- users send one uplink stream
- server forwards streams to others
- better scaling than mesh topology
Common SFU models:
- provider-managed SFU via SDK
- self-hosted SFU if using WebRTC stack directly
8) Security and compliance
- Use HTTPS everywhere
- Issue short-lived RTC tokens
- Encrypt media in transit
- Restrict room access
- Log access and call events
- Consider GDPR/HIPAA depending on your app domain
9) Recommended “fastest path”
If you want to ship quickly:
- Pick a provider like Agora, Twilio, or Daily
- Build backend token generation
- Implement call invite/accept flow
- Add push notifications
- Add native call UI
- Test on devices and optimize
10) Suggested tech stack example
- Mobile: Swift + Kotlin, or Flutter/React Native with native RTC support
- Backend: Node.js / Go / Python
- Realtime: WebSocket + push notifications
- RTC: Agora/Twilio/Daily or WebRTC + coturn
- Database: Postgres
- Push: APNs + FCM
If you want, I can give you one of these next:
- a step-by-step architecture for 1:1 calls
- a sample backend token service
- iOS + Android code examples for a specific SDK
- a WebRTC-from-scratch implementation plan