スタートガイド
インストール手順と、このプラグインの完全な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アシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:
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';クイックスタート
「クイックスタート」セクションIntercomを設定するには capacitor.config または loadWithKeys() を以下のAPIより前に呼び出してください。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.loadWithKeys({ appId: 'your-app-id', apiKeyIOS: 'ios-api-key', apiKeyAndroid: 'android-api-key',});await CapgoIntercom.registerIdentifiedUser({ userId: '42', email: 'user@example.com' });await CapgoIntercom.displayMessenger();例:ヘルプセンターの記事
セクション「例:ヘルプセンターの記事」await CapgoIntercom.displayArticle({ articleId: '12345' });例:未読バッジ
セクション「例:未読バッジ」await CapgoIntercom.addListener('unreadCountDidChange', ({ count }) => { setBadge(count);});よくある落とし穴
「よくある落とし穴」セクション- キー:呼び出し
loadWithKeys()または、他のAPIを呼び出す前にIntercomのキーを設定してください。 - ログアウト:呼び出し
logout()ユーザーの識別情報が漏洩するのを防ぐため、アプリのユーザーがサインアウトした際に実行してください。 - Web:メッセンジャーAPIはネイティブ環境のみで利用可能です。
API の概要
「API 概要」セクションloadWithKeys
「loadWithKeys」セクション実行時に 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
「registerIdentifiedUser」セクション特定済みのユーザーを Intercom に登録します。 userId または email の少なくとも一方は必須です。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerIdentifiedUser({ userId: 'user-id-123', email: 'user@example.com',});registerUnidentifiedUser
「registerUnidentifiedUser」セクションIntercom に匿名ユーザーを登録します。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerUnidentifiedUser();updateUser
「updateUser」セクションIntercom のユーザー属性を更新します。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.updateUser({ userId: 'user-id-123' });logout
「logout」セクションIntercomからユーザーをログアウトします。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logout();logEvent
「logEvent」セクションIntercomでカスタムイベントを記録します。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logEvent({ name: 'example' });displayMessenger
「displayMessenger」セクションIntercomのメッセンジャーを開きます。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessenger();displayMessageComposer
「displayMessageComposer」セクションメッセージが入力済みの状態でメッセージコンポーザーを開きます。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessageComposer({ message: 'Hello from Capacitor' });displayHelpCenter
「displayHelpCenter」セクションIntercom ヘルプセンターを開く
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayHelpCenter();hideMessenger
「hideMessenger」セクションIntercom メッセンジャーを非表示にする
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideMessenger();displayLauncher
「displayLauncher」セクションIntercom ランチャーボタンを表示する
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayLauncher();hideLauncher
「hideLauncher」セクションIntercomのランチャーボタンを非表示にします。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideLauncher();displayInAppMessages
セクション「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
「setUserHash」セクション本人確認用の HMAC を設定します。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserHash({ hmac: 'hmac' });setUserJwt
「setUserJwt」セクションセキュアなメッセンジャー認証用の JWT を設定します。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserJwt({ jwt: 'jwt' });setBottomPadding
「setBottomPadding」セクションIntercom メッセンジャー UI の下部パディングを設定します。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setBottomPadding({ value: 1 });sendPushTokenToIntercom
「sendPushTokenToIntercom」セクションIntercomにプッシュ通知トークンを送信します。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.sendPushTokenToIntercom({ value: 'value' });receivePush
「receivePush」セクション受信したIntercomのプッシュ通知を処理します。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.receivePush({});getUnreadConversationCount
「getUnreadConversationCount」セクション現在のユーザーの未読会話数を取得します。
import { CapgoIntercom } from '@capgo/capacitor-intercom';
const result = await CapgoIntercom.getUnreadConversationCount();console.log(result);型リファレンス
「型リファレンス」セクションIntercomLoadOptions
「IntercomLoadOptions」セクションexport interface IntercomLoadOptions { appId?: string; apiKeyIOS?: string; apiKeyAndroid?: string;}IntercomIdentifiedUserOptions
「IntercomIdentifiedUserOptions」セクションexport interface IntercomIdentifiedUserOptions { userId?: string; email?: string;}IntercomUserUpdateOptions
「IntercomUserUpdateOptions」セクションexport interface IntercomUserUpdateOptions { userId?: string; email?: string; name?: string; phone?: string; languageOverride?: string; customAttributes?: { [key: string]: any }; companies?: IntercomCompany[];}IntercomLogEventOptions
「IntercomLogEventOptions」セクションexport interface IntercomLogEventOptions { name: string; data?: { [key: string]: any };}IntercomMessageComposerOptions
「IntercomMessageComposerOptions」セクションexport interface IntercomMessageComposerOptions { message: string;}IntercomCarouselOptions
「IntercomCarouselOptions」セクションexport interface IntercomCarouselOptions { carouselId: string;}IntercomArticleOptions
「IntercomArticleOptions」セクションexport interface IntercomArticleOptions { articleId: string;}IntercomSurveyOptions
「IntercomSurveyOptions」セクションexport interface IntercomSurveyOptions { surveyId: string;}IntercomUserHashOptions
「IntercomUserHashOptions」セクションexport interface IntercomUserHashOptions { hmac: string;}IntercomUserJwtOptions
「IntercomUserJwtOptions」セクションexport interface IntercomUserJwtOptions { jwt: string;}IntercomBottomPaddingOptions
「IntercomBottomPaddingOptions」セクションexport interface IntercomBottomPaddingOptions { value: number;}IntercomPushTokenOptions
「IntercomPushTokenOptions」セクションexport interface IntercomPushTokenOptions { value: string;}Source of Truth
「Source Of Truth」セクションこのページはプラグインの src/definitions.tsから生成されています。upstream で公開 API が変更されたら、再度 sync を実行してください。
Getting Startedの続きを進める
「Getting Started からの続き」セクション使用している場合 スタートガイド ダッシュボードと API の運用を計画するには、これを次と連携させます @capgo/capacitor-intercom の使用方法 @capgo/capacitor-intercom を使用して Native Build の機能を利用する場合、 API の概要 「API の概要」の実装の詳細については、 はじめに 「はじめに」における実装の詳細については、 API キー および「API Keys」の実装の詳細については、 デバイス 実装の詳細については Devices を参照してください。