@capgo/capacitor-intercom

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

Intercom Capacitor plugin

原始使用文档
文档目录38 节
  1. ➡️ Get started for free
  2. Key features
  3. Why Capacitor Intercom?
  4. Documentation
  5. Compatibility
  6. Install
  7. Configuration
  8. iOS
  9. Android
  10. API
  11. loadWithKeys(...)
  12. registerIdentifiedUser(...)
  13. registerUnidentifiedUser()
  14. updateUser(...)
  15. logout()
  16. logEvent(...)
  17. displayMessenger()
  18. displayMessageComposer(...)
  19. displayHelpCenter()
  20. hideMessenger()
  21. displayLauncher()
  22. hideLauncher()
  23. displayInAppMessages()
  24. hideInAppMessages()
  25. displayCarousel(...)
  26. displayArticle(...)
  27. displaySurvey(...)
  28. setUserHash(...)
  29. setUserJwt(...)
  30. setBottomPadding(...)
  31. sendPushTokenToIntercom(...)
  32. receivePush(...)
  33. getUnreadConversationCount()
  34. addListener('windowDidShow', ...)
  35. addListener('windowDidHide', ...)
  36. addListener('unreadCountDidChange', ...)
  37. removeAllListeners()
  38. Interfaces

@capgo/capacitor-intercom

Add Intercom chat, help center and in-app messages to your Capacitor app with the native Intercom SDKs 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-intercom in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-intercom to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-intercom for Capacitor apps

Key features

  • Setup and users: loadWithKeys(), registerIdentifiedUser(), registerUnidentifiedUser(), updateUser() and logout().
  • Messenger: displayMessenger(), displayMessageComposer(), hideMessenger() and launcher visibility controls.
  • Content: displayHelpCenter(), displayArticle() and displayCarousel().
  • Events: logEvent(), the unreadCountDidChange listener, plus windowDidShow and windowDidHide on iOS.
  • In-app messages: displayInAppMessages() and hideInAppMessages().
  • Platforms: iOS and Android. Uses the official Intercom SDKs. Not available on web.

Why Capacitor Intercom?

A fully re-implemented Intercom plugin for Capacitor 8, built to Capgo quality standards:

  • Intercom iOS SDK 19+ - Latest Swift APIs with proper async handling
  • Intercom Android SDK 17+ - Modern Intercom client integration
  • Bug-free - Fixed known bugs from community implementations (e.g. hideInAppMessages on Android)
  • Cross-platform - Consistent API across iOS and Android
  • Full feature set - Messenger, Help Center, Articles, Carousels, Push, Identity Verification, and more

Essential for any app integrating Intercom for customer support, onboarding, or in-app messaging.

Documentation

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

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-intercom` 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-intercom
npx cap sync

Configuration

Add your Intercom keys to your Capacitor config:

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

Alternatively, you can initialize at runtime using loadWithKeys().

iOS

The Intercom iOS SDK (~> 19.0) is included automatically via CocoaPods or Swift Package Manager.

Push Notifications

  1. Disable Intercom's auto push integration, Add this to your Info.plist to prevent conflicts with Capacitor's push handling:
<key>IntercomAutoIntegratePushNotifications</key>
<false/>
  1. Forward the device token to Capacitor, In your 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. Register for push and handle notification taps, In your app's 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);
  }
});

Note: The plugin automatically registers the APNs device token with Intercom when it detects .capacitorDidRegisterForRemoteNotifications. You must still upload your APNs Authentication Key (.p8) in the Firebase Console under Project Settings → Cloud Messaging → APNs Authentication Key.

Android

The Intercom Android SDK (17.4.2) is included automatically via Gradle.

Push Notifications

Since Android only allows one FirebaseMessagingService, this plugin does not register its own. Instead it provides IntercomFcmHelper, a static helper you call from your app's service.

  1. Create your own FirebaseMessagingService in your app (e.g. 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. Register it in your app's AndroidManifest.xml:
<service
    android:name=".MyFirebaseMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

This approach is compatible with any other Firebase plugin, you control the routing.

API

loadWithKeys(...)

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

Initialize Intercom with API keys at runtime. Use this if you prefer not to configure keys in capacitor.config.

ParamType
optionsIntercomLoadOptions

registerIdentifiedUser(...)

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

Register a known user with Intercom. At least one of userId or email must be provided.

ParamType
optionsIntercomIdentifiedUserOptions

registerUnidentifiedUser()

registerUnidentifiedUser() => Promise<void>

Register an anonymous user with Intercom.


updateUser(...)

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

Update user attributes in Intercom.

ParamType
optionsIntercomUserUpdateOptions

logout()

logout() => Promise<void>

Log the user out of Intercom.


logEvent(...)

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

Log a custom event in Intercom.

ParamType
optionsIntercomLogEventOptions

displayMessenger()

displayMessenger() => Promise<void>

Open the Intercom messenger.


displayMessageComposer(...)

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

Open the message composer with a pre-filled message.

ParamType
optionsIntercomMessageComposerOptions

displayHelpCenter()

displayHelpCenter() => Promise<void>

Open the Intercom help center.


hideMessenger()

hideMessenger() => Promise<void>

Hide the Intercom messenger.


displayLauncher()

displayLauncher() => Promise<void>

Show the Intercom launcher button.


hideLauncher()

hideLauncher() => Promise<void>

Hide the Intercom launcher button.


displayInAppMessages()

displayInAppMessages() => Promise<void>

Enable in-app messages from Intercom.


hideInAppMessages()

hideInAppMessages() => Promise<void>

Disable in-app messages from Intercom.


displayCarousel(...)

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

Display a specific Intercom carousel.

ParamType
optionsIntercomCarouselOptions

displayArticle(...)

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

Display a specific Intercom article.

ParamType
optionsIntercomArticleOptions

displaySurvey(...)

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

Display a specific Intercom survey.

ParamType
optionsIntercomSurveyOptions

setUserHash(...)

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

Set the HMAC for identity verification.

ParamType
optionsIntercomUserHashOptions

setUserJwt(...)

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

Set JWT for secure messenger authentication.

ParamType
optionsIntercomUserJwtOptions

setBottomPadding(...)

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

Set the bottom padding for the Intercom messenger UI.

ParamType
optionsIntercomBottomPaddingOptions

sendPushTokenToIntercom(...)

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

Send a push notification token to Intercom.

ParamType
optionsIntercomPushTokenOptions

receivePush(...)

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

Handle a received Intercom push notification.

ParamType
notificationIntercomPushNotificationData

getUnreadConversationCount()

getUnreadConversationCount() => Promise<IntercomUnreadCountResult>

Get the number of unread conversations for the current user.

Returns: Promise<IntercomUnreadCountResult>


addListener('windowDidShow', ...)

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

Listen for when the Intercom window is shown.

ParamType
eventName'windowDidShow'
listenerFunc() => void

Returns: Promise<PluginListenerHandle>


addListener('windowDidHide', ...)

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

Listen for when the Intercom window is hidden.

ParamType
eventName'windowDidHide'
listenerFunc() => void

Returns: Promise<PluginListenerHandle>


addListener('unreadCountDidChange', ...)

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

Listen for changes in the unread conversation count.

ParamType
eventName'unreadCountDidChange'
listenerFunc(data: IntercomUnreadCountResult) => void

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all event listeners.


Interfaces

IntercomLoadOptions

PropType
appIdstring
apiKeyIOSstring
apiKeyAndroidstring

IntercomIdentifiedUserOptions

PropType
userIdstring
emailstring

IntercomUserUpdateOptions

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

IntercomCompany

PropType
companyIdstring
namestring
planstring
monthlySpendnumber
createdAtnumber
customAttributes{ [key: string]: any; }

IntercomLogEventOptions

PropType
namestring
data{ [key: string]: any; }

IntercomMessageComposerOptions

PropType
messagestring

IntercomCarouselOptions

PropType
carouselIdstring

IntercomArticleOptions

PropType
articleIdstring

IntercomSurveyOptions

PropType
surveyIdstring

IntercomUserHashOptions

PropType
hmacstring

IntercomUserJwtOptions

PropType
jwtstring

IntercomBottomPaddingOptions

PropType
valuenumber

IntercomPushTokenOptions

PropType
valuestring

IntercomPushNotificationData

IntercomUnreadCountResult

PropType
countnumber

PluginListenerHandle

PropType
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 Capacitor plugin

如何安装 @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 和提交记录判断。