Introduction
Imagine your bot opens a position, the market reverses sharply, and you find out 5 seconds later — when the price has already hit your stop-loss. Delay in mobile monitoring directly translates into losses. We develop mobile applications that connect to your trading bot via WebSocket — latency under 200 ms, 25 times faster than REST polling every 5 seconds. Our experience shows that a properly implemented transport with exponential backoff and state synchronization ensures data freshness even on unstable networks. Our team of certified iOS, Android, and Flutter developers delivers the project turnkey in 5–7 working days. With over 5 years building high-performance solutions for the financial sector, this case is one of our typical projects.
How WebSocket Transport Works
REST polling every 5 seconds introduces up to 5 seconds of delay and unnecessary load. WebSocket maintains a persistent connection, delivering data by event. The bot backend emits events: position_opened, position_closed, order_filled, pnl_updated. Apple's official documentation for URLSessionWebSocketTask has been supported since iOS 13.
Comparison of approaches:
| Parameter |
WebSocket |
REST Polling |
| Latency |
200 ms |
5+ seconds |
| Network load |
Minimal |
High (requests every 5s) |
| Background operation |
Requires push |
Only when app active |
| Implementation complexity |
Medium |
Low |
On iOS, implementation via URLSessionWebSocketTask:
actor BotMonitorConnection {
private var webSocketTask: URLSessionWebSocketTask?
private let session = URLSession.shared
var onEvent: ((BotEvent) -> Void)?
func connect(botId: String, token: String) {
let url = URL(string: "wss://api.example.com/bots/\(botId)/stream?token=\(token)")!
webSocketTask = session.webSocketTask(with: url)
webSocketTask?.resume()
startListening()
}
private func startListening() {
webSocketTask?.receive { [weak self] result in
switch result {
case .success(let message):
if case .string(let text) = message,
let data = text.data(using: .utf8),
let event = try? JSONDecoder().decode(BotEvent.self, from: data) {
self?.onEvent?(event)
}
self?.startListening()
case .failure(let error):
self?.scheduleReconnect()
}
}
}
private func scheduleReconnect() {
Task {
try? await Task.sleep(nanoseconds: 3_000_000_000)
connect(botId: botId, token: token)
}
}
}
Why Exponential Backoff Is Critical for Mobile Trading
Mobile networks are unstable: subway, elevators, tower handoffs. If you simply try to reconnect every second, you risk draining the battery and blocking the socket. Exponential backoff increases the reconnection interval: 1s, 2s, 4s, 8s... up to 30s. After a successful connection, the interval resets. Additionally, after reconnection, the client requests the current state via REST (GET /bots/{id}/state) to catch up on missed events.
On Flutter with Riverpod, it's convenient to expose the connection as a StreamProvider:
@riverpod
Stream<BotEvent> botEventStream(BotEventStreamRef ref, String botId) {
final channel = WebSocketChannel.connect(
Uri.parse('wss://api.example.com/bots/$botId/stream'),
);
ref.onDispose(channel.sink.close);
return channel.stream
.map((data) => BotEvent.fromJson(jsonDecode(data as String)))
.handleError((e) => ref.invalidateSelf());
}
What to Do on Disconnection
The user must see a connection indicator: green (live), gray (reconnecting), red (offline). This is a key element of trust. We implement a step-by-step algorithm:
- On disconnect: wait 1 second, then attempt reconnection.
- On failure: double the timeout up to a maximum of 30 seconds.
- On successful reconnection: request the current state via REST.
- Update the UI with the indicator.
What Data Is Displayed on Screen
The app is divided into three main zones:
Open Positions. Pair, side (Long/Short), size, entry price, current price, unrealized PnL in % and USD. PnL updates on every pnl_updated event — we only redraw the changed row, not the whole list. On Android, DiffUtil in RecyclerView; on Flutter, ListView.builder with keys.
Event Feed. The last N events: "Opened position BTC/USDT long 0.01 BTC @ 67,430", "Order filled", "Stop-loss triggered". All with timestamps.
Session Metrics. Number of trades, total realized PnL, win rate. Updates on every position_closed.
Event types in detail:
| Event |
Description |
Frequency |
| position_opened |
New position opened |
On event |
| position_closed |
Position closed |
On event |
| pnl_updated |
PnL update |
Every 500 ms |
| order_filled |
Order executed |
On event |
Push Notifications for Critical Events
WebSocket is the primary channel for the active screen. But when the app is backgrounded, events are delivered via FCM/APNs: stop-loss triggered, bot error, significant PnL change. Push notifications don't replace real-time but complement it. We configure filtering to avoid spam: only events marked as critical by the backend.
Trust and Experience
Our engineers hold Apple (iOS) and Google (Android) certifications. With 5+ years in the field, we have delivered over 20 projects for the financial sector, including trading terminals, portfolio monitors, and bot dashboards. Every app undergoes code review, load testing, and security checks.
What's Included in the Work
- WebSocket client with exponential backoff reconnection
- Connection status indicator (live/reconnecting/offline)
- Open positions list with live PnL (efficient updates)
- Event feed with auto-scroll
- REST state synchronization on reconnect
- Push via FCM/APNs for background alerts
- Documentation and integration guide
Timeline and Cost
Development time is 5–7 working days. If the backend already sends WebSocket events, the mobile part takes 4–5 days. Cost is calculated individually after analyzing requirements and architecture.
Contact us to discuss your project. Our specialists will evaluate your bot's logic for free, propose an optimal architecture, and provide an accurate estimate. Get a consultation today.
Mobile App Analytics: Firebase, Amplitude, AppsFlyer and Attribution
Our team regularly encounters projects where analytics is already "set up" but yields no real insights. A typical example is a startup with 50k DAU: tracking dozens of events without a single answer to the question "why don't users reach payment?". In two weeks we built a basic funnel and found that 70% of users drop off at the phone number verification screen. After fixing the bug, retention increased by 12%. The takeaway: analytics should start with specific questions, not tracking everything indiscriminately.
Why Event Taxonomy is the Foundation of Mobile App Analytics?
Firebase Analytics, Amplitude, Mixpanel — technically similar. The difference lies in what you put into them. A common mistake: events like screen_view, button_tap_1, button_tap_2 without context. A month later, no one remembers what button_tap_2 means.
Proper taxonomy: object + action + context. product_viewed, checkout_started, payment_completed with parameters product_id, category, price, source. This allows building funnels, cohort analysis, and retention without additional tracking.
We document the naming convention in a tracking plan — a document (Google Sheet or Amplitude Data Catalog) describing every event, its parameters, and triggering conditions. The tracking plan is synced with the analytics team before development begins, not after. This approach ensures that data remains interpretable months later and doesn't become a dump. Experience from 50+ projects confirms: without a tracking plan, analytics maintenance costs increase 2-3 times due to rework.
What Should You Choose for Mobile App Analytics: Firebase, Amplitude, or Mixpanel?
The table below highlights key differences between the three popular platforms. Choice depends on budget, traffic, and tasks.
| Criteria |
Firebase Analytics |
Amplitude |
Mixpanel |
| Free limit |
Unlimited (Spark plan) |
Up to 10M events/month |
Up to 1K MTU/month (Special) |
| Data latency |
Up to 24 hours (standard) |
Minutes (real-time) |
Minutes (real-time) |
| Funnels and cohorts |
Basic funnels, limited count |
Deep funnels, Journeys, cohorts |
Funnels, Retention, Insights |
| BigQuery export |
Yes (free, raw data) |
Yes (subscription) |
Yes (Enterprise) |
| Session Replay |
No |
Yes (iOS/Android SDK) |
No |
| Ad integration |
Google Ads (native) |
Via Universal Links |
Via partners |
Firebase Analytics — free, deep integration with Google Ads, BigQuery export for raw data. Limitations: data latency up to 24 hours, limited funnels. For startups with Google Ads traffic, it's the first choice.
Amplitude — product analytics focused on cohorts and user journeys. Journeys (formerly Pathfinder) shows actual paths between events — not assumed funnels but real routes. Session Replay records sessions for UX analysis. The free tier up to 10M events/month is enough for most products at launch.
Mixpanel — close to Amplitude, stronger in real-time segmentation. Insights, Funnels, Retention cover 90% of product analysts' tasks.
How to Solve Multi-Channel Attribution with AppsFlyer?
Knowing where a user came from is a separate task. Firebase Attribution works only within the Google ecosystem. For multi-channel attribution (Facebook Ads, TikTok, Apple Search Ads, programmatic), an MMP (Mobile Measurement Partner) is needed.
AppsFlyer is the market leader. OneLink — universal deep link working on iOS and Android, correctly attributing installs from any channel. Protect360 — built-in fraud protection (fake installs, click injection on Android). Adjust and Branch are competitors with similar features. Branch excels in deep linking; Adjust is popular in gaming.
According to Apple, with iOS 14.5, apps must obtain user permission via ATT before collecting IDFA for tracking. AppsFlyer uses probabilistic matching (IP + user agent + timing) for these users — accuracy is lower but better than nothing. SKAdNetwork and Privacy Preserving Attribution provide aggregated data from Apple with a 24-72 hour delay.
How to Set Up Crash Analytics to Not Miss Bugs?
Firebase Crashlytics is the standard for crash reporting. It automatically groups crashes by stack trace, shows affected users %, and sends velocity alerts when crash rate increases by more than 10% per hour.
Important: symbolication. On iOS, .dSYM files must be automatically uploaded with each build — via Fastlane upload_symbols_to_crashlytics or Xcode Cloud built-in. Without symbols, crashes in Crashlytics appear as memory addresses. This happens more often than expected when switching to a new CI — in one project with 500k users, we found that 40% of crashes remained unsymbolicated due to a missing CI/CD step. After automation, bug response time dropped from 3 hours to 15 minutes.
For React Native and Flutter, @sentry/react-native and sentry_flutter provide additional context: breadcrumbs, network requests before the crash, Redux/Provider state.
Below is a comparison of popular crash analytics tools to choose according to your needs.
| Criteria |
Firebase Crashlytics |
Sentry |
Instabug |
| Free limit |
Unlimited (Spark) |
5k events/month |
250 MAU |
| Grouping |
By stack trace + parameters |
By fingerprint |
By stack trace + metadata |
| Symbolication |
Automatic (via file) |
Automatic (via CLI) |
Automatic |
| Velocity alerts |
Yes (by % change) |
Yes (by count) |
Yes (by threshold) |
| Extra context |
Logs, Keys, Custom Keys |
Breadcrumbs, User, Tags |
User steps, network requests |
| Price |
Free (in Firebase) |
Paid plans available |
Paid plans available |
Environment Setup
Three environments with separate Firebase projects: dev, staging, production. Mixing analytics from test sessions and production is a common mistake that skews all metrics. On iOS via GoogleService-Info.plist per scheme, on Android via google-services.json in each flavor folder.
Timelines: basic analytics with Firebase + Crashlytics — 3-5 days. Full tracking plan + Amplitude/Mixpanel with funnels and cohorts — 2-3 weeks. Attribution via AppsFlyer with deep linking and fraud protection — 1-2 weeks. Cost is calculated individually based on integration complexity.
What Is Included in Our Work
As part of analytics implementation, we provide:
- Development and approval of a tracking plan with product and marketing teams.
- SDK integration (Firebase, Amplitude, Mixpanel, AppsFlyer) considering your stack (Swift/Kotlin/Flutter/React Native).
- Setup of funnels, cohorts, dashboards, and alerts.
- Automation of symbolication and .dSYM upload via Fastlane.
- Documentation of events and parameters.
- Team training on the analytics platform.
- Two weeks of post-release support and tracking adjustments.
Our experience: 7 years of analytics implementation and over 80 successful projects in mobile development. We guarantee data correctness and transparency at every stage.
Contact us for a consultation on setting up analytics for your app. Request an audit of your current analytics — and we will show you which metrics you are losing.