React Native App Lifecycle Events

Reteno SDK can automatically track application lifecycle and track events that described below.

Track AppLifecycle Events

When isAutomaticAppLifecycleReportingEnabled (iOS) or appLifecycleEnabled (Android) is enabled Reteno tracks the following events:

Event NamePropertiesDescription
ApplicationInstalledversion, buildThis event fires when a user opens the application for the first time right after installation
ApplicationUpdatedversion, build, previousVersion, previousBuildThis event fires when a user opens the application after updating the application
ApplicationOpenedfromBackgroundThis event fires when a user launches or foregrounds the application after the first open
ApplicationBackgroundedapplicationOpenedTime, secondsInForegroundThis event fires when a user backgrounds the application

Track Push Subscription Events

When isAutomaticPushSubscriptionReportingEnabled (iOS) or pushSubscriptionEnabled (Android) is enabled Reteno tracks the following events:

Event NameDescription
PushNotificationsSubscribedThis event fires when a customer susbribes for push notifications
PushNotificationsUnsubscribedThis event fires when a customer unsusbribes from push notifications

Track Session Events

When isAutomaticSessionReportingEnabled (iOS) or sessionEventsEnabled (Android) is enabled Reteno tracks the following events:

Event NamePropertiesDescription
SessionStartedsessionId, startTimeThis event fires when a user's session started
SessionEndedsessionID, endTime, durationInSeconds, applicationOpenedCount, applicationBackgroundedCountThis event fires when a user's session ended

Configure Android initialization

To control or disable tracking of some events you must supply instance of LifecycleTrackingOptions.

data class LifecycleTrackingOptions(
    val appLifecycleEnabled: Boolean = true,
    val pushSubscriptionEnabled: Boolean = true,
    val sessionEventsEnabled: Boolean = true
)

Also there are 2 useful shortcuts:

  • LifecycleTrackingOptions.ALL to all categories
  • LifecycleTrackingOptions.NONE to disable all categories.

During SDK initialization

new RetenoImpl(
            /* application */ this,
            /* accessKey */ "your_access_key",
            /* config */ new RetenoConfig(
                /* isPausedInAppMessages */  false,
                /* userIdProvider */  createProvider(),
                /* lifecycleTrackingOptions */ new LifecycleTrackingOptions(
                    /* appLifecycleEnabled */ true,
                    /* pushSubscriptionEnabled */ false,
                    /* sessionEventsEnabled */ false
                )
            )
);
RetenoImpl(
        application = applicaiton,
        accessKey = "your_access_key",
        config = RetenoConfig(
            lifecycleTrackingOptions = LifecycleTrackingOptions(
                appLifecycleEnabled = true,
                pushSubscriptionEnabled = false,
                sessionEventsEnabled = false
            )
        )
)

Configure iOS initialization

To control or disable tracking of some events you must init configuration.

let configuration: RetenoConfiguration = .init(
    isAutomaticAppLifecycleReportingEnabled: Bool = true,
    isAutomaticPushSubscriptionReportingEnabled: Bool = true,
    isAutomaticSessionReportingEnabled: Bool = true,
  )
Reteno.start(apiKey: "API_KEY", configuration: configuration)

Note Ensure that the init method parameters are passed in the correct order as specified. All available parameters for init method:

public init(
    isAutomaticScreenReportingEnabled: Bool = false,
    isAutomaticAppLifecycleReportingEnabled: Bool = true,
    isAutomaticPushSubscriptionReportingEnabled: Bool = true,
    isAutomaticSessionReportingEnabled: Bool = true,
    isPausedInAppMessages: Bool = false,
    inAppMessagesPauseBehaviour: PauseBehaviour = .postponeInApps,
    isDebugMode: Bool = false
  )