-
public class PostHogAndroid.Companion
-
-
Field Summary
Fields Modifier and Type Field Description public final static PostHogAndroid.CompanionINSTANCE
-
Method Summary
Modifier and Type Method Description final UnitcapturePushNotificationOpened(Intent intent)Captures $push_notification_openedfor a notification tap carried on intent.final <T extends PostHogAndroidConfig> Unitsetup(Context context, T config)Sets up the SDK and stores it as the global singleton. final <T extends PostHogAndroidConfig> PostHogInterfacewith(Context context, T config)Creates and returns a configured SDK instance that you can hold and pass around. -
-
Method Detail
-
capturePushNotificationOpened
final Unit capturePushNotificationOpened(Intent intent)
Captures
$push_notification_openedfor a notification tap carried on intent.The SDK reads the tray intent when the launch Activity is created. A host that configures PostHog from its own runtime — Flutter and React Native reach
setup()from Dart/JS, after the launch Activity has already created, started and resumed — installs too late to see that callback, and should pass the Activity's intent here instead.Deduped by
google.message_id, so calling it alongside the automatic path cannot double-count, including across a process-death restore: on this path recently opened ids are remembered on disk, because a caller with nosavedInstanceStatecannot otherwise tell a restore — which hands the Activity back its original intent — from a real second tap. The cost of that trade is that a genuine second tap of the same notification after a process restart reads as a restore and is dropped, until that id ages out of the remembered set.No-op when intent is null or carries no push id, when
capturePushNotificationOpenedis disabled, or before setup. Events go to the shared instance, so a host that only called with is not served.Covers launch intents only. A warm-start tap arrives through
Activity.onNewIntent, which nothing here observes — pass that intent in yourself.
-
setup
final <T extends PostHogAndroidConfig> Unit setup(Context context, T config)
Sets up the SDK and stores it as the global singleton.
- Parameters:
context- Android context; the application context is retained internally.config- Android SDK configuration.
-
with
final <T extends PostHogAndroidConfig> PostHogInterface with(Context context, T config)
Creates and returns a configured SDK instance that you can hold and pass around.
Default PostHog integrations are installed only on the first instance created by either setup or with. The first instance in the host app owns those integrations, so setup order matters.
- Parameters:
context- Android context; the application context is retained internally.config- Android SDK configuration.
-
-
-
-