@capgo/capacitor-intercom

中文文档
8.2.3发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4.4万

Intercom 电容插件

中文使用文档
文档目录38 节
  1. *免费开始*
  2. 主要特点
  3. 为什么是Capacitor Intercom?
  4. 文档
  5. 兼容性
  6. 安装
  7. 配置
  8. iOS系统
  9. 机器人
  10. API 密码
  11. 装入 Keys (...)
  12. 注册识别用户(...)
  13. 未识别用户 ()
  14. 更新用户(...)
  15. 登录( c)
  16. 日志事件(...)
  17. 显示信使( )
  18. 显示MessageComposer (...)
  19. 显示帮助中心( C)
  20. 隐藏信使( C)
  21. 显示 Launcher ()
  22. 隐藏 Launcher ()
  23. 显示 ImpMessages ()
  24. 隐藏 InAppMessages ()
  25. 显示 Carousel (...)
  26. 显示文章(...)
  27. 显示调查(...)
  28. 设置 UserHash (...)
  29. 设置用户Jwt(...)
  30. 设置 BottomPadding(...)
  31. 发送 PushTokenTo Intercom (...)
  32. 接收 Push (...)
  33. 获取 Unread Conversation Count ()
  34. 添加倾听器( '窗口显示',...)
  35. 添加倾听器( '窗口隐藏',...)
  36. 添加倾听器( “ 未读的变换” ,...)
  37. 删除所有收听器( )
  38. 接口

@ capgo/ 电容- intercom

在iOS和Android上的原生Intercom SDKs中,将Intercom聊天,帮助中心和内接消息添加到您的Capacitor应用上.

Capgo - Build Capacitor apps with AI, ship updates instantly

队长:在几分钟内将修正推给您的 Capacitor 用户,在没有Mac的情况下构建已签名的iOS和Android apps,并在一击中回滚.

*免费开始*

14天无限自由审判. 不需要信用卡

🤖 建筑与AI编码代理? 安装 Capgo 技能 所以克劳德代码,代码,光标,副驾驶,或双子座CLI知道如何安装和使用 @capgo/capacitor-intercom 在您的电容应用程序中: npx skills add Cap-go/capgo-skills。然后问你的经纪人: 添加@capgo/capor-intercom到我的Capacitor应用上,并把它接上 代理设置指南 • 妇女 主机磁共振

@capgo/capacitor-intercom for Capacitor apps

主要特点

  • 设置和用户数字 : loadWithKeys(), (中文(简体) ), registerIdentifiedUser(), (中文(简体) ), registerUnidentifiedUser(), (中文(简体) ), updateUser() 财务报告和审定财务报表 logout()。 。 。 .
  • 通讯员数字 : displayMessenger(), (中文(简体) ), displayMessageComposer(), (中文(简体) ), hideMessenger() 和发射器能见度控制.
  • 内容数字 : displayHelpCenter(), (中文(简体) ), displayArticle() 财务报告和审定财务报表 displayCarousel()。 。 。 .
  • 活动数字 : logEvent(),则 unreadCountDidChange 监听器,加 windowDidShow 财务报告和审定财务报表 windowDidHide (原始内容存档于2018-03-31). On iOS.
  • 正在应用信件数字 : displayInAppMessages() 财务报告和审定财务报表 hideInAppMessages()。 。 。 .
  • 平台: iOS和Android. 互联网档案馆的存檔,存档日期2013-12-21. 使用官方的Intercom SDK. 在网上不可用.

为什么是Capacitor Intercom?

完全重新执行的 Intercom 插件 电容 8,按照 Capgo 质量标准构建:

  • Intercom iOS SDK 19+ - 最新快速API,有适当的自动处理
  • Intercom Android SDK 17+ 互联网档案馆的存檔,存档日期2013-12-02 - 现代Intercom客户集成
  • 无臭虫 - 社区实施中已知的固定错误(例如:. hideInAppMessages (Android号)
  • 跨平台 - 一致的API跨iOS和Android
  • 完整特性集 - 信使、帮助中心、文章、木卫一、推、身份验证等等

任何整合Intercom的应用程序对于客户支持、登入或应用中的信息至关重要.

文档

这里有最完整的医生: https://capgo.app/docs/plugins/intercom/ (中文(简体) )

兼容性

插件版本电容兼容性维护
联合国联合国✅
页:1页:1应要求
页:1页:1❌
页:1页:1❌

说明: 此插件的主要版本沿用了Capacitor的主要版本. 使用匹配您的 Capacitor 安装的版本( 如 Capacitor 8 的插件 v8) 。 只有最新的主要版本得到积极维护.

安装

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

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

然后使用下列提示:

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

如果您更喜欢手动设置,请通过运行以下命令来安装插件,并遵循下面的平台特定指令:

npm install @capgo/capacitor-intercom
npx cap sync

配置

将您的 Intercom 密钥添加到您的 Capacitor 配置 :

{
  "plugins": {
    "CapgoIntercom": {
      "iosApiKey": "ios_sdk-xxx",
      "iosAppId": "yyy",
      "androidApiKey": "android_sdk-xxx",
      "androidAppId": "yyy"
    }
  }
}

或者,您可以在运行时使用 loadWithKeys()。 。 。 .

iOS系统

Intercom iOS SDK (英语:~> 19.0)通过CocoaPods或Swift包管理器自动包含.

推动通知

  1. 禁用Intercom的自动驱动集成,将此添加到您的 Info.plist 防止与Capacitor的推处理相冲突:
<key>IntercomAutoIntegratePushNotifications</key>
<false/>
  1. 将设备令牌转发给 Capacitor在您的 AppDelegate.swift数字 :
import UIKit
import Capacitor

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        return true
    }

    func application(_ application: UIApplication,
                     didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        // Forward to Capacitor, the plugin's observer picks this up
        // and sends the token to Intercom automatically
        NotificationCenter.default.post(
            name: .capacitorDidRegisterForRemoteNotifications,
            object: deviceToken
        )
    }

    func application(_ application: UIApplication,
                     didFailToRegisterForRemoteNotificationsWithError error: Error) {
        NotificationCenter.default.post(
            name: .capacitorDidFailToRegisterForRemoteNotifications,
            object: error
        )
    }
}
  1. 推动和处理通知窃听器的注册在您的应用程序 JavaScript 中:
import { PushNotifications } from '@capacitor/push-notifications';
import { CapgoIntercom as Intercom } from '@capgo/capacitor-intercom';

// Request permission + register
const perm = await PushNotifications.requestPermissions();
if (perm.receive === 'granted') {
  await PushNotifications.register();
}

// Auto-forward FCM token to Intercom
PushNotifications.addListener('registration', async (token) => {
  await Intercom.sendPushTokenToIntercom({ value: token.value });
});

// When user taps a notification, tell Intercom to open the conversation
PushNotifications.addListener('pushNotificationActionPerformed', async (action) => {
  const data = action.notification?.data;
  // iOS uses 'intercom_push_type', Android uses 'receiver'
  if (data?.intercom_push_type || data?.receiver === 'intercom_sdk') {
    await Intercom.receivePush(data);
  }
});

说明: 插件在发现时会自动在 Intercom 中注册 APNs 设备令牌 .capacitorDidRegisterForRemoteNotifications。您仍然必须上传您的 APN 认证密钥( S).p8),位于火地台下 项目设置 → 云信息 → APNs 认证密钥。 。 。 .

机器人

Intercom Android SDK (英语:17.4.2)通过Gradle自动包含.

推动通知

由于Android只允许 一个 FirebaseMessagingService,此插件会 没有 自己登记。 相反,它提供 IntercomFcmHelper一个静态的助手 从你的应用服务.

  1. 创建自己的 FirebaseMessagingService 在您的应用程序中( 例如 ). app/src/main/java/.../MyFirebaseMessagingService.java:
package com.your.app;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import app.capgo.capacitor.intercom.IntercomFcmHelper;

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        if (IntercomFcmHelper.isIntercomPush(remoteMessage)) {
            IntercomFcmHelper.onMessageReceived(this, remoteMessage);
        } else {
            // Handle other push SDKs (e.g. @capacitor/push-notifications)
            // or your own notification logic here
        }
    }

    @Override
    public void onNewToken(String token) {
        IntercomFcmHelper.onNewToken(this, token);
        // Forward token to other SDKs if needed
    }
}
  1. 在您的应用程序中注册 AndroidManifest.xml数字 :
<service
    android:name=".MyFirebaseMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

此方法与其他 Firebase 插件兼容, 您可以控制路由 .

API 密码

装入 Keys (...)

loadWithKeys(options: IntercomLoadOptions) => Promise<void>

在运行时初始化 API 密钥的Intercom . 如果您不愿在 macher.config 中配置密钥, 请使用此选项 .

参数类型
optionsIntercomLoadOptions

注册识别用户(...)

registerIdentifiedUser(options: IntercomIdentifiedUserOptions) => Promise<void>

向Intercom注册已知用户. 至少必须提供一个用户ID或电子邮件 .

参数类型
optionsIntercomIdentifiedUserOptions

未识别用户 ()

registerUnidentifiedUser() => Promise<void>

向Intercom注册匿名用户.


更新用户(...)

updateUser(options: IntercomUserUpdateOptions) => Promise<void>

更新Intercom中的用户属性.

参数类型
optionsIntercomUserUpdateOptions

登录( c)

logout() => Promise<void>

将用户登录出Intercom.


日志事件(...)

logEvent(options: IntercomLogEventOptions) => Promise<void>

登录 Intercom 中的自定义事件 .

参数类型
optionsIntercomLogEventOptions

显示信使( )

displayMessenger() => Promise<void>

打开Intercom信使.


显示MessageComposer (...)

displayMessageComposer(options: IntercomMessageComposerOptions) => Promise<void>

以预填信件打开信件作曲家.

参数类型
optionsIntercomMessageComposerOptions

显示帮助中心( C)

displayHelpCenter() => Promise<void>

打开Intercom帮助中心.


隐藏信使( C)

hideMessenger() => Promise<void>

隐藏 Intercom 信使 .


显示 Launcher ()

displayLauncher() => Promise<void>

显示 Intercom 启动按钮 .


隐藏 Launcher ()

hideLauncher() => Promise<void>

隐藏 Intercom 启动按钮 .


显示 ImpMessages ()

displayInAppMessages() => Promise<void>

启用 Intercom 的应用信件 .


隐藏 InAppMessages ()

hideInAppMessages() => Promise<void>

禁用 Intercom 的应用信件 .


显示 Carousel (...)

displayCarousel(options: IntercomCarouselOptions) => Promise<void>

显示特定的Intercom旋转木马.

参数类型
optionsIntercomCarouselOptions

显示文章(...)

displayArticle(options: IntercomArticleOptions) => Promise<void>

显示特定的Intercom文章 .

参数类型
optionsIntercomArticleOptions

显示调查(...)

displaySurvey(options: IntercomSurveyOptions) => Promise<void>

显示一个特定的Intercom调查.

参数类型
optionsIntercomSurveyOptions

设置 UserHash (...)

setUserHash(options: IntercomUserHashOptions) => Promise<void>

设定用于身份验证的 HMAC .

参数类型
optionsIntercomUserHashOptions

设置用户Jwt(...)

setUserJwt(options: IntercomUserJwtOptions) => Promise<void>

设置 JWT 安全信使认证 .

参数类型
optionsIntercomUserJwtOptions

设置 BottomPadding(...)

setBottomPadding(options: IntercomBottomPaddingOptions) => Promise<void>

为 Intercom 信使 UI 设置底板 .

参数类型
optionsIntercomBottomPaddingOptions

发送 PushTokenTo Intercom (...)

sendPushTokenToIntercom(options: IntercomPushTokenOptions) => Promise<void>

向Intercom发送一个按键通知符.

参数类型
optionsIntercomPushTokenOptions

接收 Push (...)

receivePush(notification: IntercomPushNotificationData) => Promise<void>

处理收到的Intercom推送通知.

参数类型
notificationIntercomPushNotificationData

获取 Unread Conversation Count ()

getUnreadConversationCount() => Promise<IntercomUnreadCountResult>

为当前用户获取未读对讲次数 .

回返情况: Promise<IntercomUnreadCountResult>


添加倾听器( '窗口显示',...)

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

显示 Intercom 窗口时请听 .

参数类型
eventName'windowDidShow'
listenerFunc() => void

回返情况: Promise<PluginListenerHandle>


添加倾听器( '窗口隐藏',...)

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

听当Intercom窗口被隐藏时.

参数类型
eventName'windowDidHide'
listenerFunc() => void

回返情况: Promise<PluginListenerHandle>


添加倾听器( “ 未读的变换” ,...)

addListener(eventName: 'unreadCountDidChange', listenerFunc: (data: IntercomUnreadCountResult) => void) => Promise<PluginListenerHandle>

听听未读对讲数的变化.

参数类型
eventName'unreadCountDidChange'
listenerFunc(data: IntercomUnreadCountResult) => void

回返情况: Promise<PluginListenerHandle>


删除所有收听器( )

removeAllListeners() => Promise<void>

删除全部事件听众 .


接口

Intercom 路由选项

Prop类型
appIdstring
apiKeyIOSstring
apiKeyAndroidstring

互通用户选项

Prop类型
userIdstring
emailstring

用户间更新选项

Prop类型
userIdstring
emailstring
namestring
phonestring
languageOverridestring
customAttributes{ [key: string]: any; }
companiesIntercomCompany[]

公司间

Prop类型
companyIdstring
namestring
planstring
monthlySpendnumber
createdAtnumber
customAttributes{ [key: string]: any; }

IntercomLogEvent 选项

Prop类型
namestring
data{ [key: string]: any; }

互通计算机

Prop类型
messagestring

互联互通选项

Prop类型
carouselIdstring

互通条款选项

Prop类型
articleIdstring

Intercom 调查选项

Prop类型
surveyIdstring

互通用户Hash 选项

Prop类型
hmacstring

互通用户 Jwt 选项

Prop类型
jwtstring

互联

Prop类型
valuenumber

Intercom PushToken 选项

Prop类型
valuestring

互通通知数据

互联互通

Prop类型
countnumber

插件听筒

Prop类型
remove() => Promise<void>

版本与发布记录

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

版本发布日期距今
8.2.3latest2026/10/1525 天前
8.2.22026/10/1327 天前
8.2.12026/10/091 个月前
8.2.02026/10/081 个月前
8.1.152026/10/081 个月前
8.1.142026/10/081 个月前

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

@capgo/capacitor-intercom 是什么?

Intercom 电容插件

如何安装 @capgo/capacitor-intercom?

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

@capgo/capacitor-intercom 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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