cometchat-android-v5-extensions

$npx mdskill add cometchat/cometchat-skills/cometchat-android-v5-extensions

Explains CometChat Android extension architecture and custom extension creation.

  • Helps developers understand how extensions plug into the UI Kit.
  • Depends on ExtensionsDataSource, ExtensionDecorator, and built-in extensions.
  • Uses official docs and source code to verify symbols and patterns.
  • Provides guidance on disabling, enabling, or creating custom extensions.

SKILL.md

.github/skills/cometchat-android-v5-extensionsView on GitHub ↗
---
name: cometchat-android-v5-extensions
description: "Extension architecture for CometChat Android — ExtensionsDataSource, decorators, built-in extensions, and how to create custom extensions."
license: "MIT"
compatibility: "Android 7.0+; Java 8+; Kotlin 1.8+; com.cometchat:chat-uikit-android:5.x"
metadata:
  author: "CometChat"
  version: "3.0.0"
  tags: "cometchat android extensions datasource decorator polls stickers collaborative"
---

> **Ground truth:** `com.cometchat:chat-uikit-android:5.x` (legacy/maintenance-only; +`calls-sdk-android:5.x`) — resolved AAR (javap) + `ui-kit/android`. **Official docs:** https://www.cometchat.com/docs/fundamentals/extensions-overview · **Docs MCP:** `claude mcp add --transport http cometchat-docs https://www.cometchat.com/docs/mcp` (or fetch the URL directly without MCP). Verify symbols against the installed package/source before relying on them.

> **Companion skills:** `cometchat-android-v5-customization` covers DataSource decorators;
> `cometchat-android-v5-features` covers the feature catalog.

## Purpose

This skill covers the CometChat extension architecture — how extensions plug into the UI Kit, the built-in extensions, and how to create custom ones.

---

## Use this skill when

- "How do extensions work?"
- "How do I add a custom extension?"
- "How do I disable an extension?"
- Working with `ExtensionsDataSource` or `ExtensionDecorator`

## Do not use this skill when

- Enabling a backend extension or AI feature → use `cometchat-android-v5-features` (which routes to `cometchat apply-feature <id> --app-id <X>`)
- Writing custom message templates → use `cometchat-android-v5-customization`

---

## 1. Extension architecture

Extensions are split into two class types:

- **Registrar** classes (e.g. `PollsExtension`, `StickerExtension`) — extend `ExtensionsDataSource`. These are what you pass to `setExtensions(...)` to enable a built-in extension.
- **Decorator** classes (e.g. `PollsExtensionDecorator`, `StickerExtensionDecorator`) — extend `DataSourceDecorator`. These are the runtime decorators that wrap the active `DataSource` chain. The kit creates them internally; you don't construct them directly.

```
ChatConfigurator.getDataSource()
    └── SmartRepliesExtensionDecorator   (created by SmartRepliesExtension)
        └── PollsExtensionDecorator      (created by PollsExtension)
            └── StickerExtensionDecorator (created by StickerExtension)
                └── MessagesDataSource (base)
```

## 2. Built-in extensions

| Extension | Package | What it adds |
|---|---|---|
| Polls | `com.cometchat.chatuikit.extensions.polls` | Poll creation and voting in messages |
| Stickers | `com.cometchat.chatuikit.extensions.sticker` | Sticker keyboard and sticker bubbles |
| Collaborative Document | `com.cometchat.chatuikit.extensions.collaborative` | Shared document editing |
| Collaborative Whiteboard | `com.cometchat.chatuikit.extensions.collaborative` | Shared whiteboard |
| Smart Replies | `com.cometchat.chatuikit.extensions.smartreplies` | AI-powered reply suggestions |
| Message Translation | `com.cometchat.chatuikit.extensions.messagetranslation` | Translate messages |
| Text Moderation | `com.cometchat.chatuikit.extensions.textmoderation` | Profanity filtering |
| Thumbnail Generation | `com.cometchat.chatuikit.extensions.thumbnailgeneration` | Image thumbnails |

## 3. Enabling/disabling extensions

Extensions are enabled by default. To customize which extensions are active, pass a custom list to `UIKitSettingsBuilder`:

```java
List<ExtensionsDataSource> extensions = new ArrayList<>();
extensions.add(new PollsExtension());            // registrar, NOT PollsExtensionDecorator
extensions.add(new StickerExtension());         // registrar, NOT StickerExtensionDecorator
extensions.add(new SmartRepliesExtension());
// Omit extensions you don't want

UIKitSettings settings = new UIKitSettings.UIKitSettingsBuilder()
    .setAppId(APP_ID)
    .setRegion(REGION)
    .setAuthKey(AUTH_KEY)
    .setExtensions(extensions)
    .build();
```

> **Why not `PollsExtensionDecorator`?** `*ExtensionDecorator` extends `DataSourceDecorator`, not `ExtensionsDataSource` — so it won't compile when added to a `List<ExtensionsDataSource>`. The kit's runtime decorator chain is built by the registrar's `enable()` method internally; you don't add decorators directly.

## 4. Creating a custom extension

A custom extension has TWO classes:

1. A **registrar** that extends `ExtensionsDataSource` (gets added to `setExtensions(...)`)
2. A **decorator** that extends `DataSourceDecorator` (created by the registrar via `ChatConfigurator.enable(...)`)

```java
// 1. Decorator — extends DataSourceDecorator, overrides per-message behavior
public class MyExtensionDecorator extends DataSourceDecorator {
    public MyExtensionDecorator(DataSource dataSource) {
        super(dataSource);
    }
    // Override methods to add custom behavior
}

// 2. Registrar — extends ExtensionsDataSource, implements getExtensionId() + addExtension()
public class MyExtension extends ExtensionsDataSource {
    @Override
    public String getExtensionId() {
        return "my-custom-extension";
    }

    @Override
    public void addExtension() {
        // addExtension() is the ABSTRACT method you must implement. The inherited
        // concrete enable() calls it after confirming the extension is on (dashboard).
        ChatConfigurator.enable(dataSource -> new MyExtensionDecorator(dataSource));
    }
}

// Then add the registrar to UIKitSettings:
extensions.add(new MyExtension());
```

---

## Hard rules

- **Two classes per extension.** A registrar (`ExtensionsDataSource`, implements abstract `getExtensionId()` + `addExtension()`; `enable()` is inherited) and a decorator (`DataSourceDecorator`, holds the per-message override). `setExtensions(...)` wants registrars; the chain builds decorators automatically.
- **Register after init.** `ChatConfigurator.enable()` must be called after `CometChatUIKit.init()` succeeds.
- **Backend extension toggle still applies.** Even if an extension is registered client-side, it needs to be enabled on the app's backend. Use `cometchat apply-feature <id> --app-id <X>` (the CLI hits the dashboard API). For dashboard-only extensions (Giphy / Stipop / Tenor / Chatwoot / Intercom — those needing third-party API keys), the user has to enter the third-party config in the dashboard manually.

More from cometchat/cometchat-skills

SkillDescription
cometchatEntry-point for CometChat integration in any React, React Native, Angular, Android, Flutter, or iOS project — web (React/Next.js/React Router/Astro), React Native (Expo/bare), Angular (12-15), native Android (V6 stable, V5 legacy), Flutter (V6 stable, V5 legacy), and native iOS (V5 stable). Detects the framework, gathers requirements through an interactive conversation, and writes production-quality integration code.
cometchat-a11yAccessibility (a11y) for CometChat UI Kit integrations across all families — React, React Native, Angular, Android (V5/V6), iOS, Flutter. Covers WCAG 2.1 AA targets, keyboard navigation in chat, screen reader announcements (live regions for new messages), color contrast, focus management on call screens, motion-reduction support, and the cross-family checks that catch the common production a11y bugs. Cross-family — applies wherever the agent is checking accessibility.
cometchat-android-v5Entry-point dispatcher for CometChat Android UI Kit v5. Detects project setup, understands what the dev is building, and routes to the right sub-skills.
cometchat-android-v5-callsCometChat Calls SDK v5 integration for native Android (V5 stable, Java + Kotlin Views). Covers SDK setup (Cloudsmith Maven, CallAppSettings, init), the dual-SDK ringing pattern (Chat SDK initiateCall + Calls SDK joinSession), session settings, event listeners, call logs, recording, screen sharing, picture-in-picture, foreground service for ongoing calls, VoIP push via FCM + ConnectionService, audio/video/participant controls, custom UI, and in-call chat. Use in standalone mode (calls is the product) or additive mode (calls layered on top of an existing CometChat Android v5 chat integration).
cometchat-android-v5-componentsComplete catalog of CometChat Android UI Kit v5 components. Reference before writing integration code — never invent component names.
cometchat-android-v5-coreFoundational rules for CometChat Android UI Kit v5. Initialization, login, UIKitSettings builder, dependency setup, and anti-patterns. Read this first.
cometchat-android-v5-customizationCustomize CometChat components beyond theming — custom message templates, DataSource decorators, event listeners, and custom view slots.
cometchat-android-v5-featuresAdd features (calls, reactions, polls, file sharing, AI, etc.) to an already-integrated CometChat project. Routes to the right sub-flow based on feature type.
cometchat-android-v5-placementWhere to put CometChat in your Android app — Activity, Fragment, BottomSheet, Dialog, Tab, or embedded patterns.
cometchat-android-v5-productionProduction readiness for CometChat Android — server-side token auth, user management CRUD, ProGuard rules, and security checklist.