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.
  1. Make sure google-services.json is in your project directory.
  2. Upload the Service Account Key file to the Clix console.
Clix provides a Homebrew CLI for quick and easy setup. Use the install and doctor commands to automatically configure the required code and settings. For iOS projects, follow the CLI prompts to add the necessary files and configurations.

Install Clix CLI

brew tap clix-so/clix-cli &&
brew install clix-so/clix-cli/clix

Run Install Command

The install command in the Clix CLI checks for required files and configurations, and provides appropriate installation guidance through prompts.
clix install

Doctor Command

The clix doctor command checks whether the necessary code and configuration for using the Clix SDK are properly set up, and provides guidance on how to fix any issues.
clix doctor

Setup Clix - Manual Installation

Integrate Firebase and Clix to manage and send notifications effectively from Clix console.
Maven Central release (latest by date)
Clix Android SDK supports installation only via Gradle (Kotlin DSL).
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.0.0")
}
Lastly, add the plugin to your app’s build.gradle.kts :
plugins {
    id("com.google.gms.google-services") version "4.4.2"
}
Add this code to Application Class. The enpoint and logLevel parameters are optional.
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",
            ),
        )
    }
}
You also need to integrate the code for requesting notification permissions. Add the code below to your Activity file and call this function when you want to prompt the user for notification permission.If you don’t have a specific preference, we recommend adding it to MainActivity.kt and calling it inside the onCreate method.
MainActivity.kt
// If you have missing dependencies, import dependencies below.
// import android.Manifest
// import android.content.pm.PackageManager
// import android.os.Build
// import androidx.activity.result.contract.ActivityResultContracts
// import androidx.core.content.ContextCompat

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        // Your onCreate codes here
        checkAndRequestNotificationPermission()
    }

    private val requestPermissionLauncher =
            registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted: Boolean
            ->
        //             Handle permission result if needed
    }

    private fun checkAndRequestNotificationPermission() {
        val isTiramisuOrHigher = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
        if (!isTiramisuOrHigher) {
            return
        }
        val hasNotificationPermission =
            ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) ==
                PackageManager.PERMISSION_GRANTED
        if (!hasNotificationPermission) {
            requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
        }
    }
}
Run your project to verify the setup works correctly. Go to Clix console > Test Console, find the registered device, send a push message, and check if the message is received properly 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.