Skip to main content
PostHog provides native mobile SDKs for iOS, Android, React Native, and Flutter with full support for event tracking, feature flags, session replay, and user identification.

Choose Your Platform

iOS

Native Swift/Objective-C SDK

Android

Native Kotlin/Java SDK

React Native

Cross-platform React Native SDK

Flutter

Dart-based Flutter SDK

iOS Integration

Add PostHog to your Podfile:
Podfile
pod "PostHog", "~> 3.0"
Then run:
pod install

Android Integration

Add PostHog to your build.gradle dependencies:
build.gradle
dependencies {
    implementation("com.posthog:posthog-android:3.+")
}

React Native Integration

npx expo install posthog-react-native expo-file-system expo-application expo-device expo-localization

Flutter Integration

Add to your pubspec.yaml:
pubspec.yaml
dependencies:
  posthog_flutter: ^5.0.0
Then run:
flutter pub get

Common Features

All mobile SDKs support these core features:

Automatic Event Capture

  • App lifecycle events (app opened, backgrounded)
  • Screen views (automatically tracked)
  • App crashes and errors

Session Replay

Mobile session replay captures screen recordings, touch interactions, and network activity (where supported).
Mobile session replay is currently in beta. Check the session replay docs for platform availability.

Group Analytics

Track events for organizations or teams:
PostHogSDK.shared.group(
    type: "company",
    key: "company_id_123",
    groupProperties: [
        "name": "Acme Corporation",
        "plan": "enterprise"
    ]
)

Privacy & Compliance

Opt Out

All SDKs support opt-out for privacy compliance:
PostHogSDK.shared.optOut()
PostHogSDK.shared.optIn()  // Re-enable

Data Masking

Configure what data is captured:
let config = PostHogConfig(apiKey: apiKey, host: host)
config.captureScreenViews = false
config.captureElementInteractions = false

Debugging

Enable debug mode to see SDK activity:
let config = PostHogConfig(apiKey: apiKey, host: host)
config.debug = true

Best Practices

Initialize Early: Initialize PostHog as early as possible in your app lifecycle to ensure all events are captured.
Test on Real Devices: Always test on physical devices, not just simulators/emulators, to catch platform-specific issues.
Handle Permissions: Some features (like session replay) may require specific permissions. Handle these gracefully in your app.
Flush on Background: Events are automatically flushed when the app goes to background, but you can manually flush if needed.

Platform-Specific Documentation

iOS SDK

Complete iOS SDK documentation

Android SDK

Complete Android SDK documentation

React Native SDK

Complete React Native documentation

Flutter SDK

Complete Flutter SDK documentation

Next Steps

Feature Flags

Learn about mobile feature flag patterns

Session Replay

Configure mobile session replay

Group Analytics

Track B2B metrics by organization

SDK Overview

Explore all available SDKs

Build docs developers (and LLMs) love