开始使用
复制一个安装步骤和完整的Markdown指南的设置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-crisp`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/crisp/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
安装
安装bun add @capgo/capacitor-crispbunx cap sync导入
导入import { CapacitorCrisp } from '@capgo/capacitor-crisp';API概述
API概述configure
配置配置 Crisp SDK 以使用您的网站 ID。 必须在使用任何其他方法之前调用。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CrispPlugin.configure({ websiteID: 'YOUR_WEBSITE_ID' });openMessenger
Section titled “openMessenger”打开Crisp聊天窗口。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CapacitorCrisp.openMessenger();setTokenID
Section titled “setTokenID”为当前用户会话设置一个唯一的令牌ID。 用于识别和恢复之前的会话。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CapacitorCrisp.setTokenID({} as { tokenID: string });setUser
Section titled “setUser”为当前会话设置用户信息。 更新支持代理可见的用户资料。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CrispPlugin.setUser({ nickname: 'John Doe', email: 'john@example.com', phone: '+1234567890'});pushEvent
Section titled “pushEvent”将自定义事件推送到Crisp。 有助于跟踪用户行为和行为。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CrispPlugin.pushEvent({ name: 'completed_purchase', color: 'green'});setCompany
Section titled “setCompany”为当前会话设置公司信息。 将用户与 Crisp 中的公司相关联。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CrispPlugin.setCompany({ name: 'Acme Corp', url: 'https://acme.com', employment: ['CEO', 'Executive'], geolocation: ['USA', 'San Francisco']});setInt
Section titled “setInt”为用户会话设置自定义整数数据字段。 存储与用户会话相关的数字数据。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CrispPlugin.setInt({ key: 'user_level', value: 42 });setString
Section titled “setString”为用户会话设置自定义字符串数据字段。 存储与用户会话相关的文本数据。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CrispPlugin.setString({ key: 'subscription_tier', value: 'premium' });sendMessage
Section titled “sendMessage”从用户发送消息到聊天。 以用户键入的方式程序化地发送消息。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CrispPlugin.sendMessage({ value: 'Hello, I need help!' });setSegment
Section titled “setSegment”用于目标和组织用户的用户分段设置。 用于在 Crisp 控制台中分类用户。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CrispPlugin.setSegment({ segment: 'premium-users' });重置 Crisp 会话。 清除所有用户数据并开始一个新的会话。 在用户注销时有用。
import { CapacitorCrisp } from '@capgo/capacitor-crisp';
await CapacitorCrisp.reset();ConfigureOptions
配置 Crisp 初始化选项。复制到剪贴板
export interface ConfigureOptions { /** * Your Crisp website ID from dashboard. */ websiteID: string; /** * Optional - 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. */ locale?: string; /** * Optional - Unique token identifier for the user session continuity. */ tokenID?: string;}eventColor
Section titled “eventColor”Crisp事件的可用颜色。用于在Crisp仪表板中可视化事件分类。
export type eventColor = | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | 'pink' | 'brown' | 'grey' | 'black';真实来源
标题为“真实来源”的部分本页面是从插件生成的。 src/definitions.ts当公共API上游更改时,请重新运行同步。