Documentation

Documentation

YourOwn SetupYourOwn SDKYourOwn API
Sphere SetupSphere SDKSphere API
  • Resources

›Getting started

Getting started

  • Copilot.cx Mobile SDK
  • Importing the iOS SDK
  • Importing the Android SDK
  • SDK configuration

Getting started for flutter

  • Importing the Copilot.cx Android SDK for Flutter
  • Importing the Copilot.cx iOS SDK for Flutter
  • Interacting with the Copilot.cx SDK in Dart

Getting around

  • Hello Copilot

Reference

  • Application
  • Authentication
  • User
  • Thing
  • In-app messages
  • Report

Event reporting guide

  • Predefined events
  • Custom events

Appendix

  • Releases
  • Open source mapping

Importing the Android SDK

Requirements

  • Android 5.0(Lollipop) and above.

Installation

The Copilot.cx Android SDK is available via private maven repository, here few steps to follow in order to install successfully the Android SDK:

  1. In your project’s general build.gradle file,under the allProjects.repositories add the following node:
allprojects {
    repositories {
        maven {
            url "https://mymavenrepo.com/repo/i0DkV5KtDEuOB0P66JPC/"
            credentials {
                username 'myMavenRepo'
                password 'yawetagtoa'
        }
    }
}
  1. In your app’s module build.gradle file, please add the following dependency (please refer the releases page for to get specific version):
implementation 'com.copilot:copilot-api-access:YOUR_COPILOT_ANDROID_SDK_VERSION_HERE'

💡If you are using support-library (or any other clashing dependency), please consider excluding Copilot’s transitive dependencies as shown below:

implementation ('com.copilot:copilot-api-access:YOUR_COPILOT_ANDROID_SDK_VERSION_HERE'){
    exclude group: 'com.android.support', module: 'support-media-compat'
    exclude group: 'com.android.support', module: 'animated-vector-drawable'
    exclude group: 'com.android.support', module: 'support-v4'
}
  1. In your AndroidManifest.xml, add the Copilot.cx application configuration under the <application> tag:
<meta-data
    android:name="com.copilot.ENVIRONMENT_URL"
    android:value="COPILOT_ENVIRONMENT_URL_HERE"/>

<meta-data
    android:name="com.copilot.APPLICATION_ID"
    android:value="YOUR_APPLICATION_ID_HERE"/>

<meta-data
    android:name="com.copilot.IS_GDPR_COMPLIANT"
    android:value="IS_APPLICATION_GDPR_COMPLIANT(true/false)"/>
    
<meta-data
    android:name="com.copilot.MANAGE_TYPE"
    android:value="Sphere"/>
  1. Replace COPILOT_ENVIRONMENT_URL_HERE, YOUR_APPLICATION_ID_HERE and IS_APPLICATION_GDPR_COMPLIANT(true/false) with the appropriate values (please refer the SDK configuration section)

  2. Add the FirebaseAnalyticsEventLogProvider class implementing the EventLogProvider interface to your project.

Android (Java)
Android (Kotlin)
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;

import com.copilot.analytics.AnalyticsConstants;
import com.copilot.analytics.EventLogProvider;
import com.google.firebase.analytics.FirebaseAnalytics;

import java.util.Map;

public class FirebaseAnalyticsEventLogProvider implements EventLogProvider {

private static final String TAG = FirebaseAnalyticsEventLogProvider.class.getSimpleName();

@NonNull
private final Context mContext;

public FirebaseAnalyticsEventLogProvider(@NonNull Context context) {
mContext = context.getApplicationContext();
deactivate();
}

@Override
public String getProviderName() {
return TAG;
}

@Override
public void activate() {
FirebaseAnalytics.getInstance(mContext).setAnalyticsCollectionEnabled(true);
}

@Override
public void deactivate() {
FirebaseAnalytics.getInstance(mContext).setAnalyticsCollectionEnabled(false);
}

@Override
public void setUserId(String userId) {
FirebaseAnalytics.getInstance(mContext).setUserId(userId);
}

@Override
public Map<String, String> transformParameters(Map<String, String> parameters) {
return parameters;
}

@Override
public void logEvent(@NonNull String eventName, Map<String, String> transformedParams) {
Bundle bundle = buildEventBundle(transformedParams);
FirebaseAnalytics.getInstance(mContext).logEvent(eventName, bundle);
}

private Bundle buildEventBundle(Map<String, String> parameters) {
Bundle params = new Bundle();

for (Map.Entry<String, String> parameter : parameters.entrySet()) {
String key = parameter.getKey();
String value = parameter.getValue();
params.putString(key, value);
}
return params;
}
}
import android.content.Context
import android.os.Bundle
import com.copilot.analytics.EventLogProvider
import com.google.firebase.analytics.FirebaseAnalytics

class FirebaseAnalyticsEventLogProvider(context: Context) : EventLogProvider {
private val context: Context = context.applicationContext

companion object {
private val TAG = FirebaseAnalyticsEventLogProvider::class.java.simpleName
}

init {
deactivate()
}

override fun getProviderName(): String = TAG

override fun activate() {
FirebaseAnalytics.getInstance(context).setAnalyticsCollectionEnabled(true)
}

override fun deactivate() {
FirebaseAnalytics.getInstance(context).setAnalyticsCollectionEnabled(false)
}

override fun setUserId(userId: String?) {
FirebaseAnalytics.getInstance(context).setUserId(userId)
}

override fun transformParameters(parameters: Map<String, String>) = parameters

override fun logEvent(eventName: String, transformedParams: Map<String, String>?) {
val bundle = buildEventBundle(transformedParams)
FirebaseAnalytics.getInstance(context).logEvent(eventName, bundle)
}

private fun buildEventBundle(parameters: Map<String, String>?) = Bundle().apply {
parameters?.forEach { (k, v) -> putString(k, v) }
}
}
  1. Initialize the Copilot.cx SDK in your Application class with the ApplicationContext and a list of LogProviders as shown below (please refer the Managing providers section).
Android (Java)
Android (Kotlin)
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();

List<EventLogProvider> providers = new ArrayList<>();
providers.add(new FirebaseAnalyticsEventLogProvider(this));
Copilot.setup(this, providers)
.enableDebugLogs();
}
}
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Copilot.setup(this, listOf(FirebaseAnalyticsEventLogProvider(this)))
.enableDebugLogs()
}
}

💡 You may add other EventLogProvider per your need. Every event will be dispatched to every provider configured in the system. It is suggested to add a console log only event provider for event dispatching debugging purposes.


Copilot logs are disabled by default. To enable them, add the enableDebugLogs() command as shown in the example, Or by calling the function through the Copilot object: Copilot.getInstance().enableDebugLogs()

  1. Add Google Firebase to your Android project following this guide : Add firebase to your Android Project. Make sure you will end up with google-services.json file in your project.
← Importing the iOS SDKSDK configuration →
  • Requirements
  • Installation
Copilot
Mail: hello@copilot.cx
Call: (212).398.0001
© Copilot.cx 2025