Erste Schritte
Kopiere einen Setup-Prompt mit den Installationsschritten und dem vollständigen Markdown-Guide für dieses Plugin.
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.
Installieren
Abschnitt „Installation“Du kannst unser KI-gestütztes Setup nutzen, um das Plugin zu installieren. Füge die Capgo Skills mit dem folgenden Befehl deinem KI-Tool hinzu:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsNutze dann diesen Prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-intercom` plugin in my project.Wenn du ein manuelles Setup bevorzugst, installiere das Plugin mit den folgenden Befehlen und befolge die plattformspezifischen Anweisungen unten:
bun add @capgo/capacitor-intercombunx cap syncImportieren
Abschnitt mit dem Titel „Import“import { CapgoIntercom } from '@capgo/capacitor-intercom';Quickstart
Abschnitt „Quick start“Konfiguriere Intercom in capacitor.config oder rufe loadWithKeys() vor den untenstehenden APIs auf.
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();Beispiel: Hilfe-Center-Artikel
Abschnitt mit dem Titel „Beispiel: Hilfe-Center-Artikel“await CapgoIntercom.displayArticle({ articleId: '12345' });Beispiel: Ungelesen-Badge
Abschnitt mit dem Titel „Beispiel: Ungelesen-Badge“await CapgoIntercom.addListener('unreadCountDidChange', ({ count }) => { setBadge(count);});Häufige Stolperfallen
Abschnitt „Häufige Fallstricke“- Keys: aufrufen
loadWithKeys()oder konfiguriere Intercom-Keys vor anderen APIs. - Logout: aufrufen
logout()wenn sich der App-User abmeldet, um Identitätslecks zu vermeiden. - Web: Messenger-APIs sind nur nativ verfügbar.
API Übersicht
Abschnitt „API Übersicht“loadWithKeys
Abschnitt „loadWithKeys“Initialisiere Intercom zur Laufzeit mit API Keys. Nutze dies, wenn du Keys nicht in capacitor.config konfigurieren möchtest.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.loadWithKeys({ appId: 'app-id-123', apiKeyIOS: 'api-key-ios', apiKeyAndroid: 'api-key-android',});registerIdentifiedUser
Abschnitt „registerIdentifiedUser“Registriere einen bekannten User bei Intercom. Mindestens eine userId oder E-Mail muss angegeben werden.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerIdentifiedUser({ userId: 'user-id-123', email: 'user@example.com',});registerUnidentifiedUser
Abschnitt „registerUnidentifiedUser“Registriere einen anonymen User bei Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerUnidentifiedUser();updateUser
Abschnitt „updateUser“Aktualisiere die User-Attribute in Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.updateUser({ userId: 'user-id-123' });Logge den User bei Intercom aus.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logout();logEvent
Abschnitt „logEvent“Logge ein Custom Event in Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logEvent({ name: 'example' });displayMessenger
Abschnitt mit dem Titel „displayMessenger“Öffne den Intercom Messenger.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessenger();displayMessageComposer
Abschnitt mit dem Titel „displayMessageComposer“Öffne den Message Composer mit einer vorausgefüllten Nachricht.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessageComposer({ message: 'Hello from Capacitor' });displayHelpCenter
Abschnitt mit dem Titel „displayHelpCenter“Öffne das Intercom Help Center.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayHelpCenter();hideMessenger
Abschnitt mit dem Titel „hideMessenger“Blende den Intercom Messenger aus.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideMessenger();displayLauncher
Abschnitt mit dem Titel „displayLauncher“Zeige den Intercom Launcher-Button an.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayLauncher();hideLauncher
Abschnitt mit dem Titel „hideLauncher“Blende den Intercom-Launcher-Button aus.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideLauncher();displayInAppMessages
Abschnitt „displayInAppMessages“In-App-Nachrichten von Intercom aktivieren.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayInAppMessages();hideInAppMessages
Abschnitt „hideInAppMessages“In-App-Nachrichten von Intercom deaktivieren.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideInAppMessages();displayCarousel
Abschnitt „displayCarousel“Ein bestimmtes Intercom-Carousel anzeigen.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayCarousel({ carouselId: 'carousel-id-123' });displayArticle
Abschnitt „displayArticle“Einen bestimmten Intercom-Artikel anzeigen.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayArticle({ articleId: 'article-id-123' });displaySurvey
Abschnitt „displaySurvey“Zeigt eine spezifische Intercom-Umfrage an.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displaySurvey({ surveyId: 'survey-id-123' });setUserHash
Abschnitt „setUserHash“Setzt den HMAC zur Identitätsverifizierung.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserHash({ hmac: 'hmac' });setUserJwt
Abschnitt „setUserJwt“Setzt das JWT für die sichere Messenger-Authentifizierung.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserJwt({ jwt: 'jwt' });setBottomPadding
Abschnitt „setBottomPadding“Setzt das untere Padding für die Intercom-Messenger-UI.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setBottomPadding({ value: 1 });sendPushTokenToIntercom
Abschnitt mit dem Titel „sendPushTokenToIntercom“Sende einen Push-Token an Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.sendPushTokenToIntercom({ value: 'value' });receivePush
Abschnitt mit dem Titel „receivePush“Verarbeite eine empfangene Intercom-Push-Notification.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.receivePush({});getUnreadConversationCount
Abschnitt mit dem Titel „getUnreadConversationCount“Rufe die Anzahl ungelesener Konversationen für den aktuellen User ab.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
const result = await CapgoIntercom.getUnreadConversationCount();console.log(result);Typreferenz
Abschnitt mit dem Titel „Typreferenz“IntercomLoadOptions
Abschnitt mit dem Titel „IntercomLoadOptions“export interface IntercomLoadOptions { appId?: string; apiKeyIOS?: string; apiKeyAndroid?: string;}IntercomIdentifiedUserOptions
Abschnitt „IntercomIdentifiedUserOptions“export interface IntercomIdentifiedUserOptions { userId?: string; email?: string;}IntercomUserUpdateOptions
Abschnitt „IntercomUserUpdateOptions“export interface IntercomUserUpdateOptions { userId?: string; email?: string; name?: string; phone?: string; languageOverride?: string; customAttributes?: { [key: string]: any }; companies?: IntercomCompany[];}IntercomLogEventOptions
Abschnitt „IntercomLogEventOptions“export interface IntercomLogEventOptions { name: string; data?: { [key: string]: any };}IntercomMessageComposerOptions
Abschnitt „IntercomMessageComposerOptions“export interface IntercomMessageComposerOptions { message: string;}IntercomCarouselOptions
Abschnitt „IntercomCarouselOptions“export interface IntercomCarouselOptions { carouselId: string;}IntercomArticleOptions
Abschnitt „IntercomArticleOptions“export interface IntercomArticleOptions { articleId: string;}IntercomSurveyOptions
Abschnitt „IntercomSurveyOptions“export interface IntercomSurveyOptions { surveyId: string;}IntercomUserHashOptions
Abschnitt „IntercomUserHashOptions“export interface IntercomUserHashOptions { hmac: string;}IntercomUserJwtOptions
Abschnitt „IntercomUserJwtOptions“export interface IntercomUserJwtOptions { jwt: string;}IntercomBottomPaddingOptions
Abschnitt „IntercomBottomPaddingOptions“export interface IntercomBottomPaddingOptions { value: number;}IntercomPushTokenOptions
Abschnitt „IntercomPushTokenOptions“export interface IntercomPushTokenOptions { value: string;}Source of Truth
Abschnitt mit dem Titel „Source of Truth“Diese Seite wird aus dem Plugin generiert src/definitions.ts. Führe den Sync erneut aus, wenn sich das öffentliche API upstream ändert.
Weiter geht's nach Getting Started
Abschnitt: „Weiter geht’s mit Getting Started“Wenn du es nutzt Erste Schritte um Dashboard- und API-Operationen zu planen, verbinde es mit @capgo/capacitor-intercom verwenden für die native Funktion in „@capgo/capacitor-intercom verwenden“, API Übersicht für Details zur Implementierung im API Overview, Einführung für die Implementierungsdetails in der Einleitung, API Schlüssel für das Implementierungsdetail in API Keys und Geräte für das Implementierungsdetail in Devices.