Flutter push notifications
Register iOS and Android devices for push notifications with the PostHog Flutter SDK, and capture when users open them. Before you start, connect a push channel.
Requirements
- Flutter SDK 5.35.0 or later. Later sections give the versions that some features need.
- Push set up in your app, for example with
firebase_messaging, and notification permission from the user. - iOS 14 or later for automatic registration and open capture on iOS.
Push isn't supported on Flutter web, macOS, Windows, or Linux.
CocoaPods is becoming read-only. CocoaPods trunk becomes read-only on December 2, 2026, and
posthog-ios4.0 and later is only published through Swift Package Manager (SPM).
posthog_flutter6.0 and later usesposthog-ios4.0 and installs on iOS and macOS through SPM only. It has no podspec. It needs Xcode 26 or later, iOS 15, and macOS 12. Flutter 3.44 and later turn SPM on by default. See the Flutter migration guide.
posthog_flutter5.x stays onposthog-ios3.x through CocoaPods or SPM. If your app can't use SPM, stay on 5.x. That includes a Flutter module embedded in an iOS app on Flutter earlier than 3.50, which installs module plugins with CocoaPods.
posthog_flutter6.0 also needs Flutter 3.41 or later on every platform, including Android and web.flutter pub getfails on an older Flutter.
Register the device
The SDK registers the device and captures opens by default:
On iOS, the SDK registers the APNs token under your bundle ID when your app registers for remote notifications. On Android, it fetches the FCM token at startup and registers it under your Firebase project ID.
iOS reports a notification tap only to UNUserNotificationCenter.current().delegate. A new Flutter app doesn't set one, and neither does flutter_local_notifications. Without it, the SDK can't capture any opens on iOS.
Set the delegate in ios/Runner/AppDelegate.swift:
With debug = true on PostHogConfig, the SDK logs a warning if the delegate is still missing shortly after setup.
The Android startup fetch doesn't see later token changes, so forward them:
Register manually
If you manage tokens yourself, set capturePushNotificationSubscriptions to false and register the token after setup() completes. The SDK drops a token that you register earlier, without an error.
Without an appId, iOS registers an APNs token under your bundle ID, and Android registers an FCM token under your Firebase project ID. To register an FCM token on iOS, pass your Firebase project ID. See iOS apps that send through Firebase.
If you don't call Posthog().reset() at sign-out, unregister the device yourself:
Capture opens
From Flutter SDK 5.40.0, the SDK captures every tap on a remote notification, on both platforms, whether it launches the app or arrives while the app runs. From 5.42.1, an Android tap that arrives before Posthog().setup() runs is captured once setup completes.
On Android, the SDK recognizes a tap by the google.message_id extra that Firebase puts on the intent, so it can't see push delivered outside FCM. It also can't see locally scheduled notifications, or notifications that your app draws from a foreground message. Capture those yourself:
Don't call it from FirebaseMessaging.onMessageOpenedApp or getInitialMessage(), because the SDK already captures those taps. From Flutter SDK 5.43.1, the manual call skips a notification that PostHog sent if the SDK captured it in the last 5 minutes. A handler that you add for other notifications still counts them twice.
Identity verification
If your channel uses identity verification, return a token from your backend through pushIdentityProvider:
pushIdentityProvider is a Dart callback, so it has no Info.plist or manifest setting. If your app uses com.posthog.posthog.AUTO_INIT, set it to false and call Posthog().setup() yourself. Otherwise the SDK never installs the callback.
Opt out
Set capturePushNotificationSubscriptions or capturePushNotificationOpened to false on PostHogConfig before setup().
On iOS, the SDK installs a launch hook before any Dart runs, so capturePushNotificationOpened = false stops the event but not the hook. To skip the hook, set com.posthog.posthog.CAPTURE_PUSH_NOTIFICATION_OPENED to false in Info.plist.
If your app sets up the SDK natively with com.posthog.posthog.AUTO_INIT, the Dart config doesn't apply. Set the com.posthog.posthog.CAPTURE_PUSH_NOTIFICATION_SUBSCRIPTIONS and com.posthog.posthog.CAPTURE_PUSH_NOTIFICATION_OPENED keys to false instead, in Info.plist on iOS and as <meta-data> in AndroidManifest.xml on Android.
Troubleshooting
| Problem | What to check |
|---|---|
| The token never registers | On Android, firebase-messaging is on the classpath, which firebase_messaging sets up. A manual registerPushNotificationToken call comes after setup() completes. |
| Opens aren't captured on iOS | Your AppDelegate sets UNUserNotificationCenter.current().delegate, and the device runs iOS 14 or later. |
| Opens aren't captured on Android | The push goes through FCM, and your launcher activity has android:launchMode="singleTop". Without it, the system resumes the task and doesn't deliver the tap. |
For problems that apply to every SDK, see push troubleshooting.





