Insider • Documentation • MIT License
This project demonstrates how to integrate the Insider Android SDK into a Kotlin application. It includes a fully working example with push notifications, geofence tracking, and all major SDK features.
| Requirement | Minimum |
|---|---|
| Android | API 24 (Android 7.0) |
| Kotlin | 2.0+ |
| Android Gradle Plugin | 8.0+ |
git clone git@github.com:useinsider/KotlinDemo.git
cd KotlinDemoBefore running, update the following values with your own:
- Partner Name in the module-level
app/build.gradle.kts:
val partnerName = "your_partner_name"
manifestPlaceholders["partner"] = partnerName
buildConfigField("String", "PARTNER_NAME", "\"$partnerName\"")This makes the partner name available both to the SDK's manifest configuration and to your Kotlin code via BuildConfig.PARTNER_NAME.
- Application ID: Replace the
applicationIdinapp/build.gradle.ktswith the one matching yourgoogle-services.jsonfile:
applicationId = "com.your.package.name"-
Firebase: Add your
google-services.jsonfile to theapp/directory. -
Huawei (optional): If you are using Huawei Messaging Service, add your
agconnect-services.jsonfile to theapp/directory.
The Insider SDK is hosted on a custom Maven repository. Make sure the following repository is declared in your settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://mobilesdk.useinsider.com/android") }
}
}Then add the SDK dependency in your module-level build.gradle.kts:
dependencies {
// With Huawei support
implementation("com.useinsider:insider:15.3.0")
// Without Huawei support
// implementation("com.useinsider:insider:15.3.0-nh")
// Optional: WebView support
// implementation("com.useinsider:insiderwebview:1.0.0")
}Note: Use the
-nh(no Huawei) variant if your app does not target Huawei devices. This excludes Huawei dependencies from your build.
If your app uses WebView and you want Insider to track in-app browser events, add the insiderwebview dependency. This enables the SDK to capture user interactions within WebView content.
The SDK should be initialized in your Application class:
import com.useinsider.insider.Insider
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize with your partner name (all lowercase)
Insider.Instance.init(this, "YOUR_PARTNER_NAME")
// Register callback handler for SDK events
Insider.Instance.registerInsiderCallback { data, callbackType ->
when (callbackType) {
InsiderCallbackType.NOTIFICATION_OPEN -> { /* Handle push notification tap */ }
InsiderCallbackType.INAPP_SEEN -> { /* Handle in-app message impression */ }
InsiderCallbackType.INAPP_BUTTON_CLICK -> { /* Handle in-app button interaction */ }
InsiderCallbackType.TEMP_STORE_CUSTOM_ACTION -> { /* Handle custom action */ }
InsiderCallbackType.TEMP_STORE_PURCHASE -> { /* Handle purchase */ }
InsiderCallbackType.TEMP_STORE_ADDED_TO_CART -> { /* Handle add to cart */ }
InsiderCallbackType.SESSION_STARTED -> { /* Handle session start */ }
}
}
}
}Important: Make sure your
Applicationclass is declared inAndroidManifest.xml:<application android:name=".MyApplication" ... >
To handle push notifications from Insider, create a FirebaseMessagingService and delegate Insider messages to the SDK:
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import com.useinsider.insider.Insider
class MyFirebaseMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
if (remoteMessage.data["source"] == "Insider") {
Insider.Instance.handleFCMNotification(applicationContext, remoteMessage)
return
}
}
}Register the service in your AndroidManifest.xml:
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>Don't forget to add the Firebase Messaging dependency:
dependencies {
implementation("com.google.firebase:firebase-messaging:25.0.1")
}If your app targets Huawei devices, add the Huawei repository and dependencies:
// settings.gradle.kts
maven { url = uri("https://developer.huawei.com/repo/") }
// build.gradle.kts (module)
dependencies {
implementation("com.huawei.hms:push:6.13.0.300")
}To enable geofence tracking, add the location dependency and start tracking:
// build.gradle.kts
dependencies {
implementation("com.google.android.gms:play-services-location:21.3.0")
}// In your Application class
Insider.Instance.startTrackingGeofence()This project is licensed under the MIT License. See the LICENSE file for details.
