Bug description
$push_notification_opened is never captured on Android. This is the Android counterpart to #555, which reported the same symptom on iOS.
The native SDK reads a notification tap from the launch Activity's intent in onActivityCreated, and install() only registers lifecycle callbacks — it never seeds from an Activity that already exists:
posthog-android/src/main/java/com/posthog/android/internal/PostHogActivityLifecycleCallbackIntegration.kt — onActivityCreated(), install()
In a Flutter app the SDK installs too late to see that callback. Measured in the example app on a Pixel 9 emulator:
17:54:27.516 MainActivity.onCreate
17:54:27.939 onCreate END / onStart / onResume <- all three complete
17:54:28.582 first PostHog event <- SDK installs ~640ms later
Every lifecycle callback for the launch Activity is missed. com.posthog.posthog.AUTO_INIT does not help either — plugin registration still runs inside Activity.onCreate, after the framework has dispatched onActivityCreated. This differs from iOS, where AUTO_INIT does win the race.
Separately, a tap that arrives while the app is already running is delivered to Activity.onNewIntent. Application.ActivityLifecycleCallbacks has no onNewIntent hook, so no library can observe it — the host application, or the Flutter plugin, has to forward it.
How to reproduce
- Flutter app with
posthog_flutter, configured from Dart with Posthog().setup(config).
- Cold-launch it from a notification tap (or
adb shell am start -n <pkg>/.MainActivity -e google.message_id "test").
- Observe
$screen is captured and $push_notification_opened is not.
For the warm-start case, background the app and deliver the intent to the live process (-f 0x20000000).
Expected behavior
A notification tap is captured as $push_notification_opened on Android, on a cold launch and while the app is already running, matching iOS.
Native apps that call PostHogAndroid.setup() from Application.onCreate are unaffected for cold start — the integration is registered before the launch Activity is created. The gap is specific to hosts that configure the SDK from their own runtime.
Related
Per-SDK status:
Additional context
Found while investigating #555. Push support shipped in posthog_flutter 5.35.0 (#511); cold-start capture has never worked on Flutter on either platform since then. #511 forwarded the config correctly — its tests assert that the flags reach native — but the automatic capture depends on the SDK being installed before the OS delivers the tap, which no unit test on either side of the bridge can observe.
This is not about token registration, which works.
Bug description
$push_notification_openedis never captured on Android. This is the Android counterpart to #555, which reported the same symptom on iOS.The native SDK reads a notification tap from the launch Activity's intent in
onActivityCreated, andinstall()only registers lifecycle callbacks — it never seeds from an Activity that already exists:posthog-android/src/main/java/com/posthog/android/internal/PostHogActivityLifecycleCallbackIntegration.kt—onActivityCreated(),install()In a Flutter app the SDK installs too late to see that callback. Measured in the example app on a Pixel 9 emulator:
Every lifecycle callback for the launch Activity is missed.
com.posthog.posthog.AUTO_INITdoes not help either — plugin registration still runs insideActivity.onCreate, after the framework has dispatchedonActivityCreated. This differs from iOS, whereAUTO_INITdoes win the race.Separately, a tap that arrives while the app is already running is delivered to
Activity.onNewIntent.Application.ActivityLifecycleCallbackshas noonNewIntenthook, so no library can observe it — the host application, or the Flutter plugin, has to forward it.How to reproduce
posthog_flutter, configured from Dart withPosthog().setup(config).adb shell am start -n <pkg>/.MainActivity -e google.message_id "test").$screenis captured and$push_notification_openedis not.For the warm-start case, background the app and deliver the intent to the live process (
-f 0x20000000).Expected behavior
A notification tap is captured as
$push_notification_openedon Android, on a cold launch and while the app is already running, matching iOS.Native apps that call
PostHogAndroid.setup()fromApplication.onCreateare unaffected for cold start — the integration is registered before the launch Activity is created. The gap is specific to hosts that configure the SDK from their own runtime.Related
PostHogAndroid.capturePushNotificationOpened(intent)for hosts that install too late to seeonActivityCreatedNewIntentListenerfor warm-start tapsPer-SDK status:
@posthog/react-native-plugin, which also reachessetup()from its own runtime; not yet filedAdditional context
Found while investigating #555. Push support shipped in posthog_flutter 5.35.0 (#511); cold-start capture has never worked on Flutter on either platform since then. #511 forwarded the config correctly — its tests assert that the flags reach native — but the automatic capture depends on the SDK being installed before the OS delivers the tap, which no unit test on either side of the bridge can observe.
This is not about token registration, which works.