Before trying to run Pulsate make sure you have properly installed Pulsate - https://pulsate.readme.io/v2.8.2/reference/installing-the-android-pulsate-sdk

Initializing Pulsate with SDK App ID and SDK App Key

Before you can do anything with Pulsate you need to initialize the Pulsate SDK with your SDK App ID and SDK App Key. Both can be found in your Pulsate Web App under Settings -> App Settings -> SDK Connect. You should initialize the Pulsate SDK as quickly as possible in the App lifecycle, we recommend using the Application onCreate callback.

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()

        val authData = PulsateAuthData(
            appToken,
            appSecret,
        )

        PulsateFactory.getInstance(authData)
    }
}

Starting a Pulsate session

To start a session all that you need to do is call "startPulsateSession" or "startPulsateSessionForAlias". Below we will explain both methods and what is different.

Pulsate automatically starts and ends sessions for you after you start the first session. The sessions will be automatically managed for you until you logout the user from Pulsate. If you do not need to logout the user don't do it.

❗️

Starting a Pulsate Session requires an Activity

Starting a session in the "onCreate()" method of your Application class is not supported.
Pulsate requires an active activity to start, so wait for the first Activity "onCreate" callback before starting a session.

Simple Session - startPulsateSession

Simple Sessions use a "Device Guid" to identify this user on this device. Everytime "Device Guid" changes a new user is created and the old user data can no longer be connected to the new user.
If the user has multiple devices or updates his current device each device will have a different "Device Guid" and will be a different user in our system. "Device Guid" can also change if the user reinstalls the App, formats his device or clears App Data.

In order to start a simple session use the startPulsateSession: method.

val pulsateManager = PulsateFactory.getInstance()
pulsateManager.startPulsateSession(object : IPulsateRequestListener {
		override fun onSuccess() {
		}

		override fun onError(e: Throwable?) {
		}
})

Deduping Session - startPulsateSessionForAlias

Deduping is the process of setting a unique identifier for a user as their customer alias so that we can recognise when that user uses your app on multiple devices. Deduping helps to improve data quality by ensuring that the same user can have multiple devices added to their profile instead of different Pulsate profiles being created for each device.

The customer alias can be any identifier that you choose that will not change for that user. Customer Number is an example of a suitable identifier that would make a good alias because customer number is a parameter that is unlikely to change. Conversely, an email address is not a good choice as an identifier because there is a strong possibility that a user could change their email in the future.

In order to use the deduping feature, you need to use the startPulsateSessionForAlias: method, instead of startPulsateSession on the PulsateManager. You need to pass the unique client identifier as the parameter.

val pulsateManager = PulsateFactory.getInstance()
pulsateManager.startPulsateSessionForAlias(
		alias = "my_user_alias",
    object : IPulsateRequestListener {
    		override fun onSuccess() {
        }

        override fun onError(e: Throwable?) {
        }
})

3. Logout

If your user logs out, in order for him to stop sending data and getting new campaigns you need to call the logoutCurrentAlias method.

Logout causes the current device to be detached from the user / alias.
This means that Pulsate will no longer be able to reach this user with any campaigns.
Pushes, In Apps, Feed Posts will not be delivered.
The user can not be segmented based on this device data.
This is almost like a "soft delete".
Use only when you want to totally logout the user from Pulsate and disable all Pulsate features.

Pulsate automatically starts and ends sessions for you after you start the first session. The sessions will be automatically managed for you until you logout the user from Pulsate. If you do not need to logout the user don't do it.

❗️

Logout prevents users from receiving Pulsate Campaigns

If you use the Pulsate Logout functionality, the User will no longer receive any Pulsate Campaigns or Journeys to their device, including Push Notifications. Logging a User out will also prevent the Pulsate SDK from sending other Events to Pulsate that may trigger a Campaign or Journey, such as GeoFence or Beacon events. If you wish for your User's to continue receiving Campaigns or Journeys to their device, do not call Logout.

val pulsateManager = PulsateFactory.getInstance()
pulsateManager.logoutCurrentAlias(object : IPulsateRequestListener {
		override fun onSuccess() {
    }

    override fun onError(e: Throwable?) {
    }
})