メインコンテンツへスキップ

スタートガイド

GitHub

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-intercom
bunx 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 キーを使用して Intercom を初期化します。 capacitor.config でのキー設定を避けたい場合に利用してください。

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

特定済みのユーザーを Intercom に登録します。 userId または email の少なくとも一方は必須です。

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

Intercom に匿名ユーザーを登録します。

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

Intercom のユーザー属性を更新します。

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

Intercomからユーザーをログアウトします。

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

Intercomでカスタムイベントを記録します。

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

Intercomのメッセンジャーを開きます。

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

メッセージが入力済みの状態でメッセージコンポーザーを開きます。

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

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' });

セキュアなメッセンジャー認証用の JWT を設定します。

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

Intercom メッセンジャー UI の下部パディングを設定します。

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

Intercomにプッシュ通知トークンを送信します。

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

受信したIntercomのプッシュ通知を処理します。

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

現在のユーザーの未読会話数を取得します。

import { CapgoIntercom } from '@capgo/capacitor-intercom';
const result = await CapgoIntercom.getUnreadConversationCount();
console.log(result);
export interface IntercomLoadOptions {
appId?: string;
apiKeyIOS?: string;
apiKeyAndroid?: string;
}
export interface IntercomIdentifiedUserOptions {
userId?: string;
email?: string;
}
export interface IntercomUserUpdateOptions {
userId?: string;
email?: string;
name?: string;
phone?: string;
languageOverride?: string;
customAttributes?: { [key: string]: any };
companies?: IntercomCompany[];
}
export interface IntercomLogEventOptions {
name: string;
data?: { [key: string]: any };
}
export interface IntercomMessageComposerOptions {
message: string;
}
export interface IntercomCarouselOptions {
carouselId: string;
}
export interface IntercomArticleOptions {
articleId: string;
}
export interface IntercomSurveyOptions {
surveyId: string;
}
export interface IntercomUserHashOptions {
hmac: string;
}
export interface IntercomUserJwtOptions {
jwt: string;
}
export interface IntercomBottomPaddingOptions {
value: number;
}
export interface IntercomPushTokenOptions {
value: string;
}

このページはプラグインの 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 を参照してください。