Developer Guide

Android App Lifecycle Events

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

The AppLifecycle Category

  1. ApplicationInstalled - event sent when application is launched the first time after installation.
    Parameters:
    • versionName - application versionName
    • build - application versionCode or longVersionCode if api version >= 28
  2. ApplicationUpdated - event sent when application is launched after the update. Update means that application versionName or versionCode has changed.
    Parameters:
    • versionName - application versionName
    • build - application versionCode or longVersionCode if api version >= 28
    • previousVersion - application old versionName
    • previousBuild - application old versionCode or longVersionCode if api version >= 28
  3. ApplicationOpened - event sent every time app goes foreground.
    Parameters:
    • wasBackgrounded - true if application opened from background and false if application launched after it's been closed.
  4. ApplicationBackgrounded - event sent every time app goes background. For android it means after ProcessLifecycleOwner OnStop would be received.
    Parameters:
    • applicationOpenedTime - time at which app was opened
    • secondsInForeground - how much seconds user spent in the foreground

The PushSubscription Category

  1. PushNotificationsSubscribed - when notification permissions change it's state to true
  2. PushNotificationsUnsubscribed - when notification permissions change it's state to false

The Sessions Category

  1. SessionStarted - when new user session is initialized.
    Parameters:
    • sessionID - new autogenerated session identifier
    • startTime - session start time
  2. SessionEnded - when user session ended.
    • sessionID - session identifier
    • endTime - session end time
    • durationInSeconds - duration of this session in seconds
    • applicationOpenedCount - how much times application was opened during this session
    • applicationBackgroundedCount - how much times application was backgrounded during this session

Control or Disable AppLifecycle Event Tracking

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.

There are 2 ways to let SDK know about LifecycleTrackingOptions:

  1. During SDK Initialization

RetenoImpl(
        application = applicaiton,
        accessKey = "your_access_key",
        config = RetenoConfig(
            lifecycleTrackingOptions = LifecycleTrackingOptions(
                appLifecycleEnabled = true,
                pushSubscriptionEnabled = false,
                sessionEventsEnabled = false
            )
        )
)

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

  1. After SDK Initialization

reteno.setLifecycleEventConfig(LifecycleTrackingOptions.ALL)

reteno.setLifecycleEventConfig(LifecycleTrackingOptions.Companion.getALL());