Prise en main
Copiez un prompt de configuration incluant les étapes d'installation et le guide markdown complet pour ce 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.
Installer
Section intitulée « Installation »Vous pouvez utiliser notre configuration assistée par IA pour installer le plugin. Ajoutez les skills Capgo à votre outil d'IA avec la commande suivante :
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsUtilisez ensuite le prompt suivant :
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-intercom` plugin in my project.Si vous préférez une installation manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à chaque plateforme ci-dessous :
bun add @capgo/capacitor-intercombunx cap syncImporter
Section intitulée « Import »import { CapgoIntercom } from '@capgo/capacitor-intercom';Démarrage rapide
Section intitulée « Démarrage rapide »Configurez Intercom dans capacitor.config ou appelez loadWithKeys() avant les API ci-dessous.
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();Exemple : article du centre d'aide
Section intitulée « Exemple : article du centre d'aide »await CapgoIntercom.displayArticle({ articleId: '12345' });Exemple : badge non lu
Section intitulée « Exemple : badge de messages non lus »await CapgoIntercom.addListener('unreadCountDidChange', ({ count }) => { setBadge(count);});Erreurs courantes
Section intitulée « Erreurs courantes »- Clés: appelez
loadWithKeys()ou configurez les clés Intercom avant les autres API. - Déconnexion: appelez
logout()lorsque l'utilisateur se déconnecte de l'app pour éviter toute fuite d'identité. - Le Web: les API du messenger sont uniquement natives.
Aperçu de API
Section intitulée « Aperçu API »loadWithKeys
Section intitulée « loadWithKeys »Initialisez Intercom avec les clés API au runtime. Utilisez cette option si vous préférez ne pas configurer les clés dans capacitor.config.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.loadWithKeys({ appId: 'app-id-123', apiKeyIOS: 'api-key-ios', apiKeyAndroid: 'api-key-android',});registerIdentifiedUser
Section intitulée « registerIdentifiedUser »Enregistrez un utilisateur connu auprès d'Intercom. Au moins un des champs userId ou email doit être fourni.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerIdentifiedUser({ userId: 'user-id-123', email: 'user@example.com',});registerUnidentifiedUser
Section intitulée « registerUnidentifiedUser »Enregistrez un utilisateur anonyme auprès d'Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerUnidentifiedUser();updateUser
Section intitulée « updateUser »Update user attributes in Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.updateUser({ userId: 'user-id-123' });Déconnectez l'utilisateur d'Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logout();logEvent
Section intitulée « logEvent »Enregistrez un événement personnalisé dans Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logEvent({ name: 'example' });displayMessenger
Section intitulée « displayMessenger »Ouvrez le messenger Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessenger();displayMessageComposer
Section intitulée « displayMessageComposer »Ouvrez le composeur de message avec un message prérempli.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessageComposer({ message: 'Hello from Capacitor' });displayHelpCenter
Section intitulée « displayHelpCenter »Ouvrez le centre d'aide Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayHelpCenter();hideMessenger
Section intitulée « hideMessenger »Masquez le messenger Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideMessenger();displayLauncher
Section intitulée « displayLauncher »Affichez le bouton de lancement Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayLauncher();hideLauncher
Section intitulée « hideLauncher »Masquer le bouton Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideLauncher();displayInAppMessages
Section intitulée « displayInAppMessages »Activer les messages in-app d'Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayInAppMessages();hideInAppMessages
Section intitulée « hideInAppMessages »Désactiver les messages in-app d'Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideInAppMessages();displayCarousel
Section intitulée « displayCarousel »Afficher un carrousel Intercom spécifique.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayCarousel({ carouselId: 'carousel-id-123' });displayArticle
Section intitulée « displayArticle »Afficher un article Intercom spécifique.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayArticle({ articleId: 'article-id-123' });displaySurvey
Section intitulée « displaySurvey »Afficher un sondage Intercom spécifique.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displaySurvey({ surveyId: 'survey-id-123' });setUserHash
Section intitulée « setUserHash »Définir le HMAC pour la vérification de l'identité.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserHash({ hmac: 'hmac' });setUserJwt
Section intitulée « setUserJwt »Définir le JWT pour l'authentification sécurisée du messenger.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserJwt({ jwt: 'jwt' });setBottomPadding
Section intitulée « setBottomPadding »Définir le padding inférieur pour l'interface du messenger Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setBottomPadding({ value: 1 });sendPushTokenToIntercom
Section intitulée « sendPushTokenToIntercom »Envoyez un token de notification push à Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.sendPushTokenToIntercom({ value: 'value' });receivePush
Section intitulée « receivePush »Gérez une notification push Intercom reçue.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.receivePush({});getUnreadConversationCount
Section intitulée « getUnreadConversationCount »Récupérez le nombre de conversations non lues pour l'utilisateur actuel.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
const result = await CapgoIntercom.getUnreadConversationCount();console.log(result);Référence de type
Section intitulée « Référence de type »IntercomLoadOptions
Section intitulée « IntercomLoadOptions »export interface IntercomLoadOptions { appId?: string; apiKeyIOS?: string; apiKeyAndroid?: string;}IntercomIdentifiedUserOptions
Section intitulée « IntercomIdentifiedUserOptions »export interface IntercomIdentifiedUserOptions { userId?: string; email?: string;}IntercomUserUpdateOptions
Section intitulée « IntercomUserUpdateOptions »export interface IntercomUserUpdateOptions { userId?: string; email?: string; name?: string; phone?: string; languageOverride?: string; customAttributes?: { [key: string]: any }; companies?: IntercomCompany[];}IntercomLogEventOptions
Section intitulée « IntercomLogEventOptions »export interface IntercomLogEventOptions { name: string; data?: { [key: string]: any };}IntercomMessageComposerOptions
Section intitulée « IntercomMessageComposerOptions »export interface IntercomMessageComposerOptions { message: string;}IntercomCarouselOptions
Section intitulée « IntercomCarouselOptions »export interface IntercomCarouselOptions { carouselId: string;}IntercomArticleOptions
Section intitulée « IntercomArticleOptions »export interface IntercomArticleOptions { articleId: string;}IntercomSurveyOptions
Section intitulée « IntercomSurveyOptions »export interface IntercomSurveyOptions { surveyId: string;}IntercomUserHashOptions
Section intitulée « IntercomUserHashOptions »export interface IntercomUserHashOptions { hmac: string;}IntercomUserJwtOptions
Section intitulée « IntercomUserJwtOptions »export interface IntercomUserJwtOptions { jwt: string;}IntercomBottomPaddingOptions
Section intitulée « IntercomBottomPaddingOptions »export interface IntercomBottomPaddingOptions { value: number;}IntercomPushTokenOptions
Section intitulée « IntercomPushTokenOptions »export interface IntercomPushTokenOptions { value: string;}Source de vérité
Section intitulée « Source de vérité »Cette page est générée à partir de src/definitions.ts. Relancez la synchronisation lorsque l’API public change en amont.
Continuer depuis Getting Started
Section intitulée « Continuer après Prise en main »Si vous utilisez Prise en main pour planifier les opérations du dashboard et de API, connectez-l’avec Utiliser @capgo/capacitor-intercom pour la fonctionnalité native dans « Utiliser @capgo/capacitor-intercom », Aperçu de API pour les détails d'implémentation dans « Vue d'ensemble de API », Introduction pour les détails d'implémentation dans l'introduction, Clés API pour les détails d'implémentation dans « Clés API », et Appareils pour les détails d'implémentation dans Devices.