Skip to main content

Best practices

Follow these practices to keep your Zoho SalesIQ Android SDK (Mobilisten) integration reliable as your app grows. Each section also names the mistake that the practice prevents.

Initialize once, early

Start the SDK once, when your app starts, and not on every screen. To do this, register the lifecycle callbacks before super.onCreate(), and call initialize() one time, in your Application class.

class MyApplication : Application() {
override fun onCreate() {
MobilistenActivityLifecycleCallbacks.register(this) // Call this before super.onCreate().
super.onCreate()
val config = SalesIQConfiguration.Builder("APP_KEY", "ACCESS_KEY").build()
ZohoSalesIQ.initialize(this, config) { /* … */ }
}
}
Avoid this mistake

Do not call register() after super.onCreate(), and do not start the SDK from an activity. The register() call gives the SDK your app's context and sets up its secure storage. If it runs late, your app does not crash, but some SDK calls have no effect until it runs. These include showing chat, turning on push notifications, and registering a visitor. To be safe, make register() the first line in onCreate().

Wait for initialization to succeed before you call other APIs

Initialization finishes in the background, so initialize() returns before the SDK is ready. Make your other calls, such as showing the chat, from its result callback, after the result succeeds.

✅ Do this. The call runs only after the SDK is ready:

ZohoSalesIQ.initialize(this, config) { result ->
if (result.isSuccess) {
ZohoSalesIQ.present()
}
}

❌ Not this. The call on the line after initialize() can run before the SDK is ready, and then it fails:

ZohoSalesIQ.initialize(this, config)
ZohoSalesIQ.present()

Set the theme with colorAccent, not attribute by attribute

colorAccent sets the main color of the whole SDK interface. Zylker Bakes, for example, sets only this attribute, to its brand color. Set it once in your SalesIQ theme:

res/values/styles.xml
<style name="Theme.SalesIQ.Base" parent="Theme.SalesIQ.Light">
<item name="colorAccent">@color/your_brand</item>
</style>
Avoid this mistake

Do not recolor the interface by overriding dozens of color attributes one at a time. It takes a long time, and the colors soon stop matching each other. Start with colorAccent, and override a specific attribute only when you want an exception. The Theme section shows how.

Never force the SDK's dependency versions

The SDK relies on other libraries, such as AndroidX, Firebase, and OkHttp, and it pins the versions that it needs. If you force one of those libraries to another version, Gradle can end up with a version that does not work with the SDK. The SDK can then fail while your app runs. Forcing usually happens through resolutionStrategy.force, strictly, or a hard-coded version.

Do not force these versions
// Do not do this.
configurations.all {
resolutionStrategy.force 'androidx.core:core-ktx:1.9.0'
}

If your own code needs a newer version, declare it with a regular implementation line instead of force. Gradle then picks the highest compatible version. The Dependencies section of the Getting started guide lists every library that the SDK includes.

Let the SDK create its workers if you use a custom WorkerFactory

Apps that use Hilt, Dagger, or Koin often provide their own WorkerFactory, which creates the app's background workers. If yours does, return null for any worker whose class name starts with com.zoho., and WorkManager falls back to the SDK's own factory. The WorkManager section of the Getting started guide shows the complete check.

Register listeners and data providers before initialize()

Listeners tell your app when something happens in the SDK, and data providers give the SDK information that it asks for. This includes both the conversation data provider and the trigger data provider. Set them once, in Application.onCreate(), before you call initialize(). They are then in place before the first event fires, so you do not miss any early callbacks. Keep them next to your initialize() call, as the Initialize once, early section describes.

Avoid registering them from an activity, or again on every screen, because that can replace or duplicate your handlers. The Listeners and Data providers sections describe each one.

Handle push only for SalesIQ messages

Your FirebaseMessagingService receives every push notification for your app, not only the SalesIQ ones. Check each message with isZohoSalesIQNotification(data) before you pass it to the SDK, so the SDK leaves your app's own notifications alone. The Push notifications guide shows the complete messaging service.