Connect
The Read/See Android SDK enables you to track user activities and update profile properties or event properties. This documentation provides step-by-step instructions for connecting with the Android SDK and getting started with tracking user activities.
Requirement
Ensure that your Android Kotlin version is 1.8.0 or later.
id 'org.jetbrains.kotlin.android' version '1.8.0'
Add the Read/See repository to your project by including the following:
repositories {
google()
mavenCentral()
}
Module Dependency (Public Repository)
Add the Read/See Android SDK to your project by including the following dependency:
dependencies {
...
implementation 'io.readsee:readsee-sdk:$sdkVersion'
}
Replace $sdkVersion
with the appropriate SDK version
Init configuration/setup Read/See client
To configure the Read/See client, obtain your API key from the Read/See dashboard after adding sources, and include the following:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Init client & setup readsee api
val tracker = ReadseeClient.config(this, "API Key goes here")
.createApi()
...
}
Ensure that the SDK is initialized with the metadata in the onCreate() of the Application class for push notifications & helpers to work.
APIs
Here’s the function that you need to call:
interface ReadseeAPIInterface {
fun ping()
fun event(eventName: String, eventData: Properties)
fun event(eventName: String, eventData: JSONObject)
fun event(eventName: String, eventData: JsonObject)
fun profile(profileData: Properties)
fun profile(profileData: JSONObject)
fun profile(profileData: JsonObject)
fun savePushToken(token: String)
fun setDistinctId(distinctId: String)
fun logout()
}
For detailed JSON parameter, please read the Read/See General SDK documentation.
ping()
For checking server status
profile()
For updating profile data on Read/See
val tracker : ReadseeAPIInterface
// update profile
val properties2 = Properties()
properties2
.addProfileDistinctId("profile_distinct_id")
.addProfileEmail("email@example.com")
.addProfileFirstname("John")
.addProfileLastname("Doe")
.addAttribute("new_field", "field_value")
tracker.profile(properties2)
// or using helper
RsTrackerHelper.profile(context, properties2)
event()
For adding an event to profile data on Read/See
val tracker : ReadseeAPIInterface
// track event
val properties = Properties()
properties
// tracking number
.addAttribute("quantity", 2)
.addAttribute("price", 5999.99)
// tracking string
.addAttribute("product", "iPhone")
tracker.event("Purchase", properties)
// or using helper
RsTrackerHelper.event(context, "Purchase", properties)
savePushToken()
For sending push notification token to Read/See
setDistinctId()
To set distinctId for readsee and send to server, u can use it when login, if you’re not set
_$distinctId
in update profilelogout()
For clearing
anonymous_id
anddistinct_id
on device when changing user or logging out
Receiving Firebase Cloud Messaging
To receive push notifications from Read/See, you need to add this class:
class ReadseeFirebaseMessagingService
Extend or just call it in manifest:
...
<service
android:name="io.readsee.sdk.client.ReadseeFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
IMPORTANT
At any time, your app's manifest file can have only one service with the intent filter com.google.firebase.MESSAGING_EVENT. If there is more than one service, only the first service will receive the callback and the Read/See SDK may never receive the Push Payload resulting in poor send rates.
Was this article helpful?