Auto-Reconnect
When your connection drops (network switch, momentary outage, server restart), CrewTalk automatically reconnects using exponential backoff:
| Attempt | Delay |
|---|---|
| 1 | 2 seconds |
| 2 | 4 seconds |
| 3 | 8 seconds |
| 4 | 15 seconds |
| 5–20 | 30 seconds |
The app makes up to 20 reconnection attempts before giving up. If all attempts fail, bringing the app to the foreground triggers a fresh connection attempt.
Both the audio relay (TCP) and message relay (WebSocket) have independent reconnection logic. One can reconnect while the other is still trying, so you might receive messages even if audio is temporarily down.
Token Refresh
Firebase authentication tokens expire after 1 hour. CrewTalk handles this proactively:
- Periodic refresh — Tokens are refreshed every 45 minutes in the background
- Pre-reconnect refresh — Before any reconnection attempt, a fresh token is obtained
- Foreground refresh — When the app returns to the foreground, the token is checked and refreshed if needed
This prevents the scenario where your connection drops due to an expired token.
Foreground Service (Android)
On Android, CrewTalk runs a foreground service that keeps the audio connection alive when the app is in the background:
- Shows a persistent notification: "CrewTalk — Connected to [hub name]"
- Uses
FOREGROUND_SERVICE_TYPE_MICROPHONEfor PTT capability - Acquires a wake lock to prevent the CPU from sleeping
- The service starts when you enter a hub and stops when you leave
Battery Optimization
CrewTalk requests exemption from Android's battery optimization to prevent the system from killing the background connection. When prompted:
- Tap Allow to exempt CrewTalk from battery restrictions
- This ensures the audio relay stays connected during long shoots
- The actual battery impact is minimal — the app only uses significant power when actively transmitting
If you denied the battery optimization prompt, you can enable it manually: Settings > Apps > CrewTalk > Battery > Unrestricted. Without this, Android may disconnect CrewTalk after a period of background use.
iOS Background Modes
On iOS, CrewTalk uses background audio and VoIP modes to maintain the connection. iOS is more restrictive about background execution, but the audio session keeps the app alive while you're connected to a hub.
Connection Recovery Flow
When your app returns to the foreground after being backgrounded:
- AppState listener detects the
activetransition - Token is refreshed to ensure validity
- WebSocket status is checked — reconnects if disconnected
- Audio relay status is checked — reconnects if disconnected
- Presence is updated to "online"
This entire flow happens in under 2 seconds on a good network connection.
Tips for Maximum Reliability
- Grant battery optimization exemption on Android
- Keep the app in the foreground when actively on set
- Use a stable network — wired or strong Wi-Fi beats congested cellular
- Monitor connection quality — the status row indicator warns you before audio breaks up
- Trust the auto-reconnect — manual disconnect/reconnect is rarely needed
