Skip to main content

Before Getting Started

Overview

Clix leverages Firebase Cloud Messaging (FCM) to deliver notifications efficiently. The goal is to ensure a smooth integration process and reliable delivery of push notifications to your app users.

Environment

  • Android API level 26 (Android 8.0) or later
  • Firebase account
Make sure you’ve completed the Firebase setup.If the setup is complete, the following items should be in place:
  • Make sure google-services.json is in your project directory.
  • Upload the Service Account Key file to the Clix console.
Clix CLI is an AI-powered assistant for quick and easy SDK setup. Use the install and doctor commands to automatically configure the required code and settings.

Install Clix CLI

npm install -g @clix-so/clix-cli

Run Install Command

The install command checks for required files and configurations, then guides you through the installation process with interactive prompts.
clix install

Doctor Command

The clix doctor command verifies that your Clix SDK setup is correct and provides guidance on fixing any issues.
clix doctor

Setup Clix - Manual Installation

Integrate Firebase and Clix to manage and send notifications effectively from Clix console.
Sonatype Central release (latest by date)

1. Installation

Clix Android SDK supports installation only via Gradle (Kotlin DSL).
If you’re using the Gradle Version Catalog (libs.versions.toml), follow the steps below for more consistent dependency management.
  1. Add the version and library alias to gradle/libs.versions.toml (create the file if it doesn’t exist):
[versions]
clix-android-sdk = "1.X.X" # Replace with the latest SDK version

[libraries]
clix-android-sdk = { module = "so.clix:clix-android-sdk", version.ref = "clix-android-sdk" }
  1. (Optional) If you use a custom catalog file name, adjust the accessor accordingly. If you’re using the default (libs), no extra configuration is required.
  2. In your app module’s build.gradle.kts:
dependencies {
  // TOML alias: clix-android-sdk -> Gradle accessor: libs.clix.android.sdk
  implementation(libs.clix.android.sdk)
}
When Gradle generates accessors, hyphens (-) in the alias are converted to dots (.) resulting in libs.clix.android.sdk.

(Option 2) Without Version Catalog (Direct Declaration)

Add the following to your project’s settings.gradle.kts or build.gradle.kts:
repositories {
  mavenCentral()
}
Add the dependency to your app’s build.gradle.kts:
dependencies {
  implementation("so.clix:clix-android-sdk:1.X.X") // Replace with the latest SDK version
}
Lastly, add the plugin to your app’s build.gradle.kts:
plugins {
  id("com.google.gms.google-services") version "4.X.X" // Replace with the latest version
}

2. Initialize Clix with Config

Add this code to your Application class. The endpoint and logLevel parameters are optional. If your project doesn’t have an Application class, refer to this link to add one.
Application.kt
import so.clix.core.Clix
import so.clix.core.ClixConfig
import so.clix.utils.logging.ClixLogLevel

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

		Clix.initialize(
            this,
            ClixConfig(
                projectId = "YOUR_PROJECT_ID",
                apiKey = "YOUR_API_KEY",
            ),
        )
    }
}

3. Add Permission Code

Add this code to your Application class, right after the Clix.initialize code.
Application.kt
import so.clix.core.Clix
import so.clix.core.ClixConfig
import so.clix.utils.logging.ClixLogLevel

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

		Clix.initialize(
      this,
      ClixConfig(
          projectId = "YOUR_PROJECT_ID",
          apiKey = "YOUR_API_KEY",
      ),
    )

    // STEP 2: Configure notification handling after initialization
    // Note: autoRequestPermission defaults to false
    Clix.Notification.configure(
      autoRequestPermission = false,  // Set to true to automatically request permission
      autoHandleLandingURL = false     // Set to true to automatically open landing URLs
    )
  }
}
By default, autoRequestPermission is set to false, which means the app will not automatically request push notification permission.There are two options to implement the push notification permission flow:

(Option 1) Automatically request permission right after app launch

Simply set autoRequestPermission to true.
Application.kt
// STEP 2: Configure notification handling after initialization
// Note: autoRequestPermission defaults to false
Clix.Notification.configure(
  autoRequestPermission = true,  // Set to true to automatically request permission
  autoHandleLandingURL = false     // Set to true to automatically open landing URLs
)

(Option 2) Manually control when to show the permission prompt

If you want to request permission at a specific point in your app, leave it as false and call the following code when you’re ready to request permission.
MainActivity.kt
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch

class MainActivity : AppCompatActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    // Call this code wherever you want to request permission from the user
    lifecycleScope.launch {
      val granted = Clix.Notification.requestPermission()
      Clix.Notification.setPermissionGranted(granted)
    }
  }
}

4. Build & Run

Run your project to verify that the setup works correctly. Go to Clix console > Test Console, find the registered device, send a test push notification, and confirm that the message is received on the device. Also, make sure the push events are being tracked in real time.
If you’re using an emulator, make sure it is started with Cold Boot to properly test push notification delivery. For more details, see this guide.