开始使用
复制一个设置提示,包含安装步骤和该插件的完整Markdown指南。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-intercom`
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/intercom/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.
安装
安装您可以使用我们的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-intercombunx cap sync导入
导入import { CapgoIntercom } from '@capgo/capacitor-intercom';API概述
API 简介loadWithKeys
__CAPGO_KEEP_0__概述在运行时使用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();updateUser
更新用户属性使用 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();hideMessenger
标题:隐藏Messenger隐藏Intercom消息推送器
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideMessenger();displayLauncher
标题:显示启动器显示Intercom启动器按钮
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayLauncher();hideLauncher
标题:隐藏启动器隐藏Intercom启动器按钮
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideLauncher();displayInAppMessages
标题:显示在应用内消息启用Intercom在应用内消息
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayInAppMessages();hideInAppMessages
标题:hideInAppMessages从 Intercom 中禁用应用内消息。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideInAppMessages();displayCarousel
标题:displayCarousel显示特定的 Intercom 轮播。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayCarousel({ carouselId: 'carousel-id-123' });displayArticle
标题:displayArticle显示特定的 Intercom 文章。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayArticle({ articleId: 'article-id-123' });displaySurvey
标题:displaySurvey显示特定的 Intercom 问卷。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displaySurvey({ surveyId: 'survey-id-123' });setUserHash
设置用户哈希设置身份验证的HMAC
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserHash({ hmac: 'hmac' });setUserJwt
设置安全消息传递的JWT设置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加载选项IntercomLoadOptions
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 设备 设备