@capgo/capacitor-crisp

中文文档
8.2.11发布于 2026/11/04MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 5.3万

Crisp native SDK for capacitor

原始使用文档
文档目录38 节
  1. ➡️ Get started for free
  2. Key features
  3. Why Capacitor Crisp?
  4. Documentation
  5. Compatibility
  6. Install
  7. Init
  8. iOS
  9. Android Integration
  10. Push Notifications
  11. Open chatbox
  12. API
  13. configure(...)
  14. openMessenger()
  15. setTokenID(...)
  16. setUser(...)
  17. pushEvent(...)
  18. setCompany(...)
  19. setInt(...)
  20. setString(...)
  21. sendMessage(...)
  22. setSegment(...)
  23. reset()
  24. addListener('messageReceived', ...)
  25. addListener('messageSent', ...)
  26. addListener('sessionLoaded', ...)
  27. addListener('chatOpened', ...)
  28. addListener('chatClosed', ...)
  29. removeAllListeners()
  30. registerPushToken(...)
  31. enableNotifications()
  32. isCrispPushNotification(...)
  33. handlePushNotification(...)
  34. setShouldPromptForNotificationPermission(...)
  35. openChatboxFromNotification()
  36. getPluginVersion()
  37. Interfaces
  38. Type Aliases

capacitor-crisp

Add Crisp live chat to your Capacitor app with the native Crisp SDKs. Open the messenger, identify users, push events and handle Crisp push notifications on iOS and Android.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-crisp in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-crisp to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-crisp for Capacitor apps

Key features

  • Messenger: configure() with your website ID, then openMessenger().
  • User data: setUser(), setCompany(), setTokenID(), setSegment() and custom setString() or setInt() fields.
  • Events and messages: pushEvent(), sendMessage() and listeners like messageReceived and chatOpened.
  • Push notifications: registerPushToken(), isCrispPushNotification() and handlePushNotification().
  • Sessions: reset() clears the current session.
  • Platforms: iOS and Android. Native Crisp SDKs on iOS and Android. Push helpers are not available on web.

Why Capacitor Crisp?

The only free Capacitor plugin for integrating Crisp.chat's native SDK into your mobile apps. Crisp is a powerful customer support and messaging platform, and this plugin provides:

  • Native SDK integration - Full access to Crisp's native mobile SDKs for iOS and Android
  • Rich messaging features - Live chat, user profiles, custom data, events, and segmentation
  • Two-way communication - Send messages programmatically and track user behavior
  • Complete API - Full feature parity with Crisp's JavaScript API

Perfect for apps needing customer support, helpdesk functionality, or user engagement tools.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/crisp/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-crisp` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-crisp
npx cap sync

Init

Call configure in your code Before any other method :

import { CapacitorCrisp } from '@capgo/capacitor-crisp';

CapacitorCrisp.configure({websiteID: '******-****-****-****-********'})

iOS

To enable your users to take and upload photos to the chat as well as download photos to their photo library, add :

Privacy - Camera Usage Description (NSCameraUsageDescription)

Privacy - Photo Library Additions Usage Description (NSPhotoLibraryAddUsageDescription)

to your app's Info.plist.

Android Integration

Nothing special to do for the chatbox itself.

Push Notifications

Crisp push notifications require credentials in your Crisp dashboard under Settings > Chatbox Settings > Push Notifications (APNs for iOS, Firebase for Android). See the Crisp iOS and Crisp Android guides for dashboard setup.

The plugin handles timing-sensitive setup natively:

  • iOS: APNs tokens from @capacitor/push-notifications are forwarded to Crisp automatically.
  • Android: enableNotifications() runs automatically inside configure().

You still need platform setup:

  1. Enable the Push Notifications capability in Xcode (iOS).
  2. Configure Firebase (google-services.json) and add firebase-messaging to your Android app (Android).
  3. Call CapacitorCrisp.configure({ websiteID: 'YOUR_WEBSITE_ID' }) before opening the messenger.

With @capacitor/push-notifications

import { CapacitorCrisp } from '@capgo/capacitor-crisp';
import { PushNotifications } from '@capacitor/push-notifications';

await CapacitorCrisp.configure({ websiteID: 'YOUR_WEBSITE_ID' });
await PushNotifications.register();

// Optional JS fallback (iOS is already handled natively)
await PushNotifications.addListener('registration', async ({ value }) => {
  await CapacitorCrisp.registerPushToken({ token: value });
});

// Forward foreground Crisp pushes so messageReceived can update your unread badge.
await PushNotifications.addListener('pushNotificationReceived', async (notification) => {
  const { isCrisp } = await CapacitorCrisp.isCrispPushNotification({ data: notification.data });
  if (isCrisp) {
    await CapacitorCrisp.handlePushNotification({ data: notification.data, openChatbox: false });
  }
});

await PushNotifications.addListener('pushNotificationActionPerformed', async (event) => {
  const { isCrisp } = await CapacitorCrisp.isCrispPushNotification({ data: event.notification.data });
  if (isCrisp) {
    await CapacitorCrisp.handlePushNotification({ data: event.notification.data });
  }
});

On iOS, disable Crisp auto-prompting if you manage permissions yourself:

await CapacitorCrisp.setShouldPromptForNotificationPermission({ enabled: false });

Android: shared FirebaseMessagingService

If you already have a custom FirebaseMessagingService, forward Crisp events with CrispFcmHelper:

import ee.forgr.plugin.crisp.CrispFcmHelper;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

public class MyFirebaseMessagingService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        if (CrispFcmHelper.isCrispNotification(remoteMessage)) {
            CrispFcmHelper.onMessageReceived(this, remoteMessage);
        }
    }

    @Override
    public void onNewToken(String token) {
        CrispFcmHelper.onNewToken(this, token);
    }
}

Android: Crisp-only notifications

If you do not use another push provider, declare CrispNotificationService in your app AndroidManifest.xml:

<service
  android:name="im.crisp.client.external.notification.CrispNotificationService"
  android:exported="false">
  <intent-filter>
    <action android:name="com.google.firebase.MESSAGING_EVENT" />
  </intent-filter>
</service>

iOS: native AppDelegate (optional)

You can also forward the APNs token directly in AppDelegate.swift:

import Crisp

func application(_ application: UIApplication,
                 didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    CrispSDK.setDeviceToken(deviceToken)
}

Open chatbox

import { CapacitorCrisp } from '@capgo/capacitor-crisp';

CapacitorCrisp.openMessenger()

API

Crisp Chat SDK Plugin for Capacitor. Provides live chat and customer support functionality through Crisp.chat.

configure(...)

configure(data: ConfigureOptions) => Promise<void>

Configure the Crisp SDK with your website ID. Must be called before using any other methods.

ParamTypeDescription
dataConfigureOptions- Configuration object

openMessenger()

openMessenger() => Promise<void>

Open the Crisp messenger chat window. Shows the chat interface to the user.


setTokenID(...)

setTokenID(data: { tokenID: string; }) => Promise<void>

Set a unique token ID for the current user session. Used to identify and restore previous conversations.

ParamTypeDescription
data{ tokenID: string; }- Token data object

setUser(...)

setUser(data: { nickname?: string; phone?: string; email?: string; signature?: string; avatar?: string; }) => Promise<void>

Set user information for the current session. Updates the user profile visible to support agents.

ParamTypeDescription
data{ nickname?: string; phone?: string; email?: string; signature?: string; avatar?: string; }- User information object

pushEvent(...)

pushEvent(data: { name: string; color: eventColor; }) => Promise<void>

Push a custom event to Crisp. Useful for tracking user actions and behavior.

ParamTypeDescription
data{ name: string; color: eventColor; }- Event data object

setCompany(...)

setCompany(data: { name: string; url?: string; description?: string; employment?: [title: string, role: string]; geolocation?: [country: string, city: string]; }) => Promise<void>

Set company information for the current session. Associates the user with a company in Crisp.

ParamTypeDescription
data{ name: string; url?: string; description?: string; employment?: [title: string, role: string]; geolocation?: [country: string, city: string]; }- Company information object

setInt(...)

setInt(data: { key: string; value: number; }) => Promise<void>

Set a custom integer data field. Stores numerical data associated with the user session.

ParamTypeDescription
data{ key: string; value: number; }- Integer data object

setString(...)

setString(data: { key: string; value: string; }) => Promise<void>

Set a custom string data field. Stores text data associated with the user session.

ParamTypeDescription
data{ key: string; value: string; }- String data object

sendMessage(...)

sendMessage(data: { value: string; }) => Promise<void>

Send a message from the user to the chat. Programmatically send a message as if the user typed it.

ParamTypeDescription
data{ value: string; }- Message data object

setSegment(...)

setSegment(data: { segment: string; }) => Promise<void>

Set a user segment for targeting and organization. Used to categorize users in the Crisp dashboard.

ParamTypeDescription
data{ segment: string; }- Segment data object

reset()

reset() => Promise<void>

Reset the Crisp session. Clears all user data and starts a fresh session. Useful when user logs out.


addListener('messageReceived', ...)

addListener(eventName: 'messageReceived', listenerFunc: (event: CrispMessageEvent) => void) => Promise<PluginListenerHandle>

Listen for incoming Crisp messages.

ParamTypeDescription
eventName'messageReceived'- messageReceived
listenerFunc(event: CrispMessageEvent) => void- Called with message metadata.

Returns: Promise<PluginListenerHandle>


addListener('messageSent', ...)

addListener(eventName: 'messageSent', listenerFunc: (event: CrispMessageEvent) => void) => Promise<PluginListenerHandle>

Listen for messages sent through Crisp.

ParamTypeDescription
eventName'messageSent'- messageSent
listenerFunc(event: CrispMessageEvent) => void- Called with message metadata.

Returns: Promise<PluginListenerHandle>


addListener('sessionLoaded', ...)

addListener(eventName: 'sessionLoaded', listenerFunc: (event: CrispSessionLoadedEvent) => void) => Promise<PluginListenerHandle>

Listen for the native Crisp session loading.

ParamTypeDescription
eventName'sessionLoaded'- sessionLoaded
listenerFunc(event: CrispSessionLoadedEvent) => void- Called with the native session ID.

Returns: Promise<PluginListenerHandle>


addListener('chatOpened', ...)

addListener(eventName: 'chatOpened', listenerFunc: () => void) => Promise<PluginListenerHandle>

Listen for the Crisp chatbox opening.

ParamTypeDescription
eventName'chatOpened'- chatOpened
listenerFunc() => void- Called when the chatbox opens.

Returns: Promise<PluginListenerHandle>


addListener('chatClosed', ...)

addListener(eventName: 'chatClosed', listenerFunc: () => void) => Promise<PluginListenerHandle>

Listen for the Crisp chatbox closing.

ParamTypeDescription
eventName'chatClosed'- chatClosed
listenerFunc() => void- Called when the chatbox closes.

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all registered listeners for this plugin.


registerPushToken(...)

registerPushToken(data: { token: string; }) => Promise<void>

Register the device push token (APNs on iOS, FCM on Android) with Crisp. Optional fallback when you cannot use native token forwarding. On iOS, the plugin forwards APNs tokens from @capacitor/push-notifications automatically via native hooks.

ParamTypeDescription
data{ token: string; }- Push token payload

enableNotifications()

enableNotifications() => Promise<void>

Enable Crisp push notifications on Android. Called automatically during configure() on Android. This JS method is an optional manual override. No-op on iOS and web.


isCrispPushNotification(...)

isCrispPushNotification(data: { data: Record<string, string>; }) => Promise<{ isCrisp: boolean; }>

Check whether a push notification payload was sent by Crisp. Useful when sharing push handling with @capacitor/push-notifications.

ParamTypeDescription
data{ data: Record<string, string>; }- Notification payload

Returns: Promise<{ isCrisp: boolean; }>


handlePushNotification(...)

handlePushNotification(data: { data: Record<string, string>; openChatbox?: boolean; }) => Promise<void>

Handle a Crisp push notification payload. On Android, opens the chatbox by default when the user taps a notification. On iOS, processes the payload through the Crisp SDK. Emits messageReceived with fromPushNotification: true for Crisp payloads, which lets apps update unread badges when the chatbox is closed.

ParamTypeDescription
data{ data: Record<string, string>; openChatbox?: boolean; }- Notification payload

setShouldPromptForNotificationPermission(...)

setShouldPromptForNotificationPermission(data: { enabled: boolean; }) => Promise<void>

Control whether Crisp auto-prompts for notification permission on iOS. No-op on Android and web.

ParamTypeDescription
data{ enabled: boolean; }- Permission prompt options

openChatboxFromNotification()

openChatboxFromNotification() => Promise<{ opened: boolean; }>

Open the Crisp chatbox from a notification tap intent on Android. Call from your main activity when handling notification open actions. No-op on iOS and web.

Returns: Promise<{ opened: boolean; }>


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the plugin version number.

Returns: Promise<{ version: string; }>


Interfaces

ConfigureOptions

Configuration for initializing Crisp.

PropTypeDescription
websiteIDstringYour Crisp website ID from dashboard.
localestringOptional - Locale to force in the Crisp chat widget (ISO 639-1), eg. en, fr, es. Web + Android: overrides the runtime locale. iOS follows the device/app locale.
tokenIDstringOptional - Unique token identifier for the user session continuity.

PluginListenerHandle

PropType
remove() => Promise<void>

CrispMessageEvent

Payload emitted when a Crisp message event is received from the native SDK or from a forwarded Crisp push notification.

PropTypeDescription
isMebooleanWhether the message was sent by the current user.
fromPushNotificationbooleanTrue when the event was emitted from a forwarded Crisp push notification.

CrispSessionLoadedEvent

Payload emitted when the Crisp session is loaded.

PropTypeDescription
sessionIdstringNative Crisp session identifier.

Type Aliases

eventColor

Available colors for Crisp events. Used to visually categorize events in the Crisp dashboard.

'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | 'pink' | 'brown' | 'grey' | 'black'

Record

Construct a type with a set of properties K of type T

{ [P in K]: T; }

版本与发布记录

@capgo/capacitor-crisp 共发布 193 个版本,首次发布于 2022/07/24;过去 12 个月发布了 59 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.2.11latest2026/11/044 天前
8.2.102026/10/1525 天前
8.2.92026/10/1327 天前
8.2.82026/10/1228 天前
8.2.72026/10/091 个月前
8.2.62026/10/091 个月前

关于 @capgo/capacitor-crisp 的常见问题

@capgo/capacitor-crisp 是什么?

Crisp native SDK for capacitor

如何安装 @capgo/capacitor-crisp?

在项目目录运行 npm install @capgo/capacitor-crisp,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-crisp 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-crisp 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-crisp 可以商用吗?

@capgo/capacitor-crisp 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-crisp 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-crisp 在 2026/10/09 – 2026/11/07 这 30 天内被下载 52,722 次,日均约 1,757 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-crisp 还在维护吗?

最新版本 8.2.11 发布于 2026/11/04(4 天前);至今共发布 193 个版本,其中过去 12 个月发布了 59 个;首次发布于 2022/07/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。