跳过内容

开始使用

GitHub

安装

安装

您可以使用我们的AI辅助设置来安装插件。将Capgo技能添加到您的AI工具中,使用以下命令:

终端窗口
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

然后使用以下提示:

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

如果您更喜欢手动设置,请按照以下命令安装插件,并遵循以下平台特定的说明:

终端窗口
bun add @capgo/capacitor-intercom
bunx cap sync

导入

导入
import { CapgoIntercom } from '@capgo/capacitor-intercom';

API概述

API 简介

在运行时使用API密钥初始化Intercom。 如果您不想在capacitor.config中配置密钥,可以使用此方法。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.loadWithKeys({
appId: 'app-id-123',
apiKeyIOS: 'api-key-ios',
apiKeyAndroid: 'api-key-android',
});

registerIdentifiedUser

注册已识别用户

使用 Intercom 注册已知用户。 至少需要提供一个 userId 或 email。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerIdentifiedUser({
userId: 'user-id-123',
email: 'user@example.com',
});

registerUnidentifiedUser

注册未识别用户

使用 Intercom 注册匿名用户。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerUnidentifiedUser();

使用 Intercom 更新用户属性。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.updateUser({ userId: 'user-id-123' });

logout

注销

使用 Intercom 注销用户。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logout();

logEvent

事件日志

在 Intercom 中记录自定义事件。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logEvent({ name: 'example' });

displayMessenger

显示消息者

打开 Intercom 消息者。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessenger();

displayMessageComposer

显示消息编辑器

打开带有预填写消息的消息编辑器。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessageComposer({ message: 'Hello from Capacitor' });

displayHelpCenter

显示帮助中心

打开 Intercom 帮助中心。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayHelpCenter();

隐藏Intercom消息推送器

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideMessenger();

显示Intercom启动器按钮

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayLauncher();

隐藏Intercom启动器按钮

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideLauncher();

启用Intercom在应用内消息

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayInAppMessages();

从 Intercom 中禁用应用内消息。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideInAppMessages();

显示特定的 Intercom 轮播。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayCarousel({ carouselId: 'carousel-id-123' });

显示特定的 Intercom 文章。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayArticle({ articleId: 'article-id-123' });

显示特定的 Intercom 问卷。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displaySurvey({ surveyId: 'survey-id-123' });

设置身份验证的HMAC

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserHash({ hmac: 'hmac' });

设置Intercom消息传递UI的底部间距

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserJwt({ jwt: 'jwt' });

setBottomPadding

设置推送通知令牌

将推送通知令牌发送到Intercom

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setBottomPadding({ value: 1 });

sendPushTokenToIntercom

设置用户哈希

设置身份验证的HMAC

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.sendPushTokenToIntercom({ value: 'value' });

receivePush

接收推送

处理已接收的Intercom推送通知

import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.receivePush({});

getUnreadConversationCount

获取当前用户未读对话数

类型参考

import { CapgoIntercom } from '@capgo/capacitor-intercom';
const result = await CapgoIntercom.getUnreadConversationCount();
console.log(result);

Intercom类型参考

Intercom加载选项
export interface IntercomLoadOptions {
appId?: string;
apiKeyIOS?: string;
apiKeyAndroid?: string;
}

IntercomIdentifiedUserOptions

获取当前用户未读对话数
export interface IntercomIdentifiedUserOptions {
userId?: string;
email?: string;
}

IntercomUserUpdateOptions

Intercom用户更新选项
export interface IntercomUserUpdateOptions {
userId?: string;
email?: string;
name?: string;
phone?: string;
languageOverride?: string;
customAttributes?: { [key: string]: any };
companies?: IntercomCompany[];
}

IntercomLogEventOptions

Intercom日志事件选项
export interface IntercomLogEventOptions {
name: string;
data?: { [key: string]: any };
}

IntercomMessageComposerOptions

Intercom消息编辑器选项
export interface IntercomMessageComposerOptions {
message: string;
}

IntercomCarouselOptions

Intercom轮播选项
export interface IntercomCarouselOptions {
carouselId: string;
}

IntercomArticleOptions

Intercom文章选项
export interface IntercomArticleOptions {
articleId: string;
}

IntercomSurveyOptions

Intercom调查选项
export interface IntercomSurveyOptions {
surveyId: string;
}

IntercomUserHashOptions

IntercomUserHash选项
export interface IntercomUserHashOptions {
hmac: string;
}

IntercomUserJwtOptions

IntercomUserJwt选项
export interface IntercomUserJwtOptions {
jwt: string;
}

IntercomBottomPaddingOptions

Intercom底部填充选项
export interface IntercomBottomPaddingOptions {
value: number;
}

IntercomPushTokenOptions

Intercom推送令牌选项
export interface IntercomPushTokenOptions {
value: string;
}

真实来源

真实来源

本页面是从插件生成的 src/definitions.ts重新同步时,公共API发生更改时,请重新运行。

如果您正在使用 开始 用于规划仪表板和API操作的 使用@capgo/capacitor-intercom 使用@capgo/capacitor-intercom 使用@API/__CAPGO_KEEP_1__-intercom API概述 __CAPGO_KEEP_0__概述 介绍 API 键 API Keys 设备 设备