Per iniziare
Copia un prompt di configurazione con i passaggi di installazione e la guida markdown completa per questo 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.
Puoi usare il nostro setup assistito dall'IA per installare il plugin. Aggiungi le skill Capgo al tuo strumento di IA usando il seguente comando:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsPoi usa il seguente prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-intercom` plugin in my project.Se preferisci la configurazione manuale, installa il plugin eseguendo questi comandi e segui le istruzioni specifiche per piattaforma qui sotto:
bun add @capgo/capacitor-intercombunx cap syncImporta
Sezione intitolata “Import”import { CapgoIntercom } from '@capgo/capacitor-intercom';Avvio rapido
Sezione intitolata “Quick start”Configura Intercom in capacitor.config o chiama loadWithKeys() prima delle API qui sotto.
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();Esempio: articolo del centro assistenza
Sezione intitolata “Esempio: articolo del centro assistenza”await CapgoIntercom.displayArticle({ articleId: '12345' });Esempio: badge messaggi non letti
Sezione intitolata “Esempio: badge non letti”await CapgoIntercom.addListener('unreadCountDidChange', ({ count }) => { setBadge(count);});Errori comuni
Sezione intitolata “Errori comuni”- Chiavi: chiamata
loadWithKeys()oppure configura le chiavi di Intercom prima delle altre API. - Logout: chiamata
logout()quando l'utente dell'app effettua il logout per evitare fughe di identità. - Web: le API del messenger sono solo native.
Panoramica API
Sezione intitolata “Panoramica API”loadWithKeys
Sezione: “loadWithKeys”Inizializza Intercom con le chiavi API a runtime. Usalo se preferisci non configurare le chiavi in capacitor.config.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.loadWithKeys({ appId: 'app-id-123', apiKeyIOS: 'api-key-ios', apiKeyAndroid: 'api-key-android',});registerIdentifiedUser
Sezione: “registerIdentifiedUser”Registra un utente noto su Intercom. È necessario fornire almeno l'userId o l'email.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerIdentifiedUser({ userId: 'user-id-123', email: 'user@example.com',});registerUnidentifiedUser
Sezione: “registerUnidentifiedUser”Registra un utente anonimo su Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerUnidentifiedUser();updateUser
Sezione: “updateUser”Aggiorna gli attributi dell'utente su Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.updateUser({ userId: 'user-id-123' });Effettua il logout dell'utente da Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logout();logEvent
Sezione intitolata “logEvent”Registra un evento personalizzato in Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logEvent({ name: 'example' });displayMessenger
Sezione intitolata “displayMessenger”Apri il messenger di Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessenger();displayMessageComposer
Sezione intitolata “displayMessageComposer”Apri il compositore di messaggi con un testo predefinito.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessageComposer({ message: 'Hello from Capacitor' });displayHelpCenter
Sezione intitolata “displayHelpCenter”Apri l'help center di Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayHelpCenter();hideMessenger
Sezione intitolata “hideMessenger”Nascondi il messenger di Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideMessenger();displayLauncher
Sezione intitolata “displayLauncher”Mostra il launcher button di Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayLauncher();hideLauncher
Sezione intitolata “hideLauncher”Nascondi il pulsante launcher di Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideLauncher();displayInAppMessages
Sezione intitolata “displayInAppMessages”Abilita i messaggi in-app di Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayInAppMessages();hideInAppMessages
Sezione intitolata “hideInAppMessages”Disabilita i messaggi in-app di Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideInAppMessages();displayCarousel
Sezione intitolata “displayCarousel”Mostra un carousel Intercom specifico.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayCarousel({ carouselId: 'carousel-id-123' });displayArticle
Sezione intitolata “displayArticle”Mostra un articolo Intercom specifico.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayArticle({ articleId: 'article-id-123' });displaySurvey
Sezione intitolata “displaySurvey”Mostra un sondaggio Intercom specifico.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displaySurvey({ surveyId: 'survey-id-123' });setUserHash
Sezione intitolata “setUserHash”Imposta l'HMAC per la verifica dell'identità.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserHash({ hmac: 'hmac' });setUserJwt
Sezione intitolata “setUserJwt”Imposta il JWT per l'autenticazione sicura del messenger.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserJwt({ jwt: 'jwt' });setBottomPadding
Sezione intitolata “setBottomPadding”Imposta il padding inferiore per l'interfaccia del messenger Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setBottomPadding({ value: 1 });sendPushTokenToIntercom
Sezione intitolata “sendPushTokenToIntercom”Invia un token di notifica push a Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.sendPushTokenToIntercom({ value: 'value' });receivePush
Sezione intitolata “receivePush”Gestisci una notifica push Intercom ricevuta.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.receivePush({});getUnreadConversationCount
Sezione intitolata “getUnreadConversationCount”Ottieni il numero di conversazioni non lette per l'utente corrente.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
const result = await CapgoIntercom.getUnreadConversationCount();console.log(result);Riferimento ai tipi
Sezione: “Type Reference”IntercomLoadOptions
Sezione intitolata “IntercomLoadOptions”export interface IntercomLoadOptions { appId?: string; apiKeyIOS?: string; apiKeyAndroid?: string;}IntercomIdentifiedUserOptions
Sezione intitolata “IntercomIdentifiedUserOptions”export interface IntercomIdentifiedUserOptions { userId?: string; email?: string;}IntercomUserUpdateOptions
Sezione intitolata “IntercomUserUpdateOptions”export interface IntercomUserUpdateOptions { userId?: string; email?: string; name?: string; phone?: string; languageOverride?: string; customAttributes?: { [key: string]: any }; companies?: IntercomCompany[];}IntercomLogEventOptions
Sezione intitolata “IntercomLogEventOptions”export interface IntercomLogEventOptions { name: string; data?: { [key: string]: any };}IntercomMessageComposerOptions
Sezione intitolata “IntercomMessageComposerOptions”export interface IntercomMessageComposerOptions { message: string;}IntercomCarouselOptions
Sezione intitolata “IntercomCarouselOptions”export interface IntercomCarouselOptions { carouselId: string;}IntercomArticleOptions
Sezione intitolata “IntercomArticleOptions”export interface IntercomArticleOptions { articleId: string;}IntercomSurveyOptions
Sezione intitolata “IntercomSurveyOptions”export interface IntercomSurveyOptions { surveyId: string;}IntercomUserHashOptions
Sezione intitolata “IntercomUserHashOptions”export interface IntercomUserHashOptions { hmac: string;}IntercomUserJwtOptions
Sezione intitolata “IntercomUserJwtOptions”export interface IntercomUserJwtOptions { jwt: string;}IntercomBottomPaddingOptions
Sezione intitolata “IntercomBottomPaddingOptions”export interface IntercomBottomPaddingOptions { value: number;}IntercomPushTokenOptions
Sezione intitolata “IntercomPushTokenOptions”export interface IntercomPushTokenOptions { value: string;}Fonte di verità
Sezione intitolata “Fonte di verità”Questa pagina è generata dal src/definitions.ts. Riesegui la sync quando il API pubblico cambia upstream.
Continua da Getting Started
Sezione intitolata “Continua da Getting Started”Se stai usando Per iniziare per pianificare le operazioni della dashboard e di API, collegalo a Utilizzo di @capgo/capacitor-intercom per la funzionalità nativa in Utilizzo di @capgo/capacitor-intercom, Panoramica API per i dettagli di implementazione in Panoramica di API, Introduzione per i dettagli di implementazione in Introduzione, Chiavi API per i dettagli di implementazione in Chiavi API, e Dispositivi per i dettagli di implementazione in Dispositivi.