Skip to main content
CometChatStickerKeyboard shows your app’s stickers: one page per sticker set, a grid of four columns, and a tab bar of set icons at the bottom. It fetches the sets itself and reports the sticker a user taps; the host sends it. The message composer opens it from its sticker button and sends the sticker you tap. You can also host it yourself.
CometChatStickerKeyboard showing a sticker set and the set tabs

Where It Fits

CometChatStickerKeyboard is a View. It fetches the sticker sets when it first appears.The composer’s sticker button opens it, as tall as the system keyboard was — at least 296 pt. Tapping a sticker sends it, and the keyboard stays open. The sticker button or a tap in the text field closes it. See Message Composer ▸ Stickers.
Stickers come from the Stickers extension, which must be enabled on your CometChat dashboard.

Quick Start

Give it a height, and handle the tap. The keyboard does not close itself:
To send the sticker to a chat, use a composer store:
With the Stickers extension turned off, onError receives ERR_EXTENSION_NOT_ENABLED.

What It Shows

The sticker keyboard showing content: a four-column grid of the selected set's stickers over a separator, and the tab bar of set icons
The texts can be replaced with emptyStateTitleText, emptyStateSubtitleText and errorStateText. A hidden state renders nothing.Sets appear in the order the extension returns them — the app’s default stickers first, then custom ones. A set’s tab icon is its first sticker. A sticker that fails to load shows a placeholder sticker. An animated GIF sticker shows its first frame in the keyboard; what is sent is the GIF’s URL.onError is called every time the keyboard enters the error state, and when it appears already in it.
Sticker carries name, url and setName, and isGif when the URL ends in .gif.

Actions and Events

Callback Methods


Functionality

loadingView, emptyView and errorView replace the states — see Custom View Slots.

Custom View Slots

Replace the loading, empty and error states. The error view receives a retry action:
Or for every sticker keyboard in a subtree, including the composer’s. An initialiser argument wins:

Advanced Methods

Store Access

CometChatStickerKeyboardStore fetches and holds the sets. Pass your own to share it, to keep the fetched stickers when the keyboard goes away, or to show fixed stickers in a preview:
A seeded store never fetches. The store also has retry(), selectStickerSet(_:), and the observable uiState, stickerSets, selectedSetIndex and currentStickers.
The keyboard sets the store’s onStickerClick to its own onStickerClick when it appears — even when that is nil — so a handler you set on an injected store is replaced. Pass the handler to the keyboard instead.

Subclassing

CometChatStickerKeyboard is a View struct. Customise it with its parameters, modifiers and style.

Objective-C

In the UIKit toolkit: The keyboard is @objc, apart from setOnStickerTap(onStickerTap:), whose Sticker is a Swift struct — from Objective-C, host it through the composer. Swift’s set(emptyStateTitleText:) is setWithEmptyStateTitleText:; set(onError:) keeps setOnError::

Accessibility

In the SwiftUI toolkit:
  • Each sticker is a button that reads as its name, or “Sticker” when it has none. Each tab is a button that reads as “name sticker set”, marked selected for the set shown.
  • The loading state reads as “Loading stickers, please wait”.
  • Under Reduce Motion, the composer fades the keyboard in and out instead of sliding it.

Style

CometChatStickerKeyboardStyle is sparse: set only what you change, and everything else follows the theme. The composer passes its stickerKeyboardStyle through:

Next Steps

Message Composer

Hosts the keyboard behind its sticker button

Create Poll

The composer’s other hosted component