Analytics
The LikeMinds SDK provides a set of predefined user events that you might want to track for your chat application.
Refer to Analytics Events to see the list of events that are being tracked.
Callback
To receive these analytics events and handle them according to your requirements implement LMChatCoreCallback
.
While setting up LikeMinds Chat SDK in onCreate()
method of the Application class, extend LMChatCoreCallback
and pass the instance of the same in LMChatCore.setup()
.
interface LMChatCoreCallback{
fun getAnalyticsEvents(eventName: String, eventProperties: Map<String, String?> = mapOf()) // will be triggered when an event is called.
}
eventName
: Name of the event triggered.eventProperties
: All the properties associated with that particular event.
Example Implementation
- Kotlin
- Java
val application = this
val enablePushNotifications = false
val deviceId = null
val domain = "ENTER YOUR DOMAIN NAME HERE"
val lmChatCoreCallback = object : LMChatCoreCallback {
override fun getAnalyticsEvents(eventName: String, eventProperties: Map<String, String?>) {
// your implementation for analytics
}
}
LMChatCore.setup(
application = application,
enablePushNotifications = enablePushNotifications,
deviceId = deviceId,
domain = domain,
lmChatCoreCallback = lmChatCoreCallback
)
Application application = this; // instance of the application
LMChatTheme chatTheme = null; // instance of the theme
String domain = "ENTER YOUR DOMAIN NAME"; // domain of the app
boolean enablePushNotifications = false; // enable or disable push notifications
String deviceId = null; // device id of the user
LMChatCoreCallback lmChatCoreCallback = new LMChatCoreCallback() {
@Override
public void getAnalyticsEvents(@NonNull String eventName, @NonNull Map<String, String> eventProperties) {
// your implementation for analytics
}
};
LMChatCore.INSTANCE.setup(
application,
lmChatCoreCallback,
chatTheme,
domain,
enablePushNotifications,
deviceId
);