Panduan Memulai
Salin prompt setup yang berisi langkah install dan panduan markdown lengkap untuk plugin ini.
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.
Anda bisa menggunakan AI-Assisted Setup kami untuk menginstal plugin ini. Tambahkan skill Capgo ke tool AI Anda dengan command berikut:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsLalu gunakan prompt berikut:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-intercom` plugin in my project.Jika Anda lebih memilih Manual Setup, instal plugin dengan menjalankan perintah berikut dan ikuti petunjuk khusus platform di bawah ini:
bun add @capgo/capacitor-intercombunx cap syncimport { CapgoIntercom } from '@capgo/capacitor-intercom';Mulai cepat
Bagian berjudul “Mulai cepat”Konfigurasi Intercom di capacitor.config atau panggil loadWithKeys() sebelum API di bawah ini.
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();Contoh: artikel help center
Bagian berjudul “Example: help center article”await CapgoIntercom.displayArticle({ articleId: '12345' });Contoh: badge belum dibaca
Bagian berjudul “Example: unread badge”await CapgoIntercom.addListener('unreadCountDidChange', ({ count }) => { setBadge(count);});Kesalahan umum
Bagian berjudul “Kesalahan umum”- Keys: panggil
loadWithKeys()atau konfigurasi Intercom keys sebelum API lainnya. - Logout: panggil
logout()saat user aplikasi sign out untuk menghindari kebocoran identitas. - Web: messenger APIs hanya tersedia untuk native.
Ringkasan API
Bagian berjudul “Ikhtisar API”loadWithKeys
Bagian berjudul “loadWithKeys”Inisialisasi Intercom dengan kunci API saat runtime. Gunakan ini jika Anda tidak ingin mengonfigurasi kunci di capacitor.config.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.loadWithKeys({ appId: 'app-id-123', apiKeyIOS: 'api-key-ios', apiKeyAndroid: 'api-key-android',});registerIdentifiedUser
Bagian berjudul “registerIdentifiedUser”Daftarkan user yang sudah dikenal ke Intercom. Minimal harus menyertakan userId atau email.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerIdentifiedUser({ userId: 'user-id-123', email: 'user@example.com',});registerUnidentifiedUser
Bagian berjudul “registerUnidentifiedUser”Daftarkan user anonim ke Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerUnidentifiedUser();updateUser
Bagian berjudul “updateUser”Perbarui atribut user di Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.updateUser({ userId: 'user-id-123' });logout
Bagian berjudul “logout”Logout user dari Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logout();logEvent
Bagian berjudul “logEvent”Log custom event di Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logEvent({ name: 'example' });displayMessenger
Bagian berjudul “displayMessenger”Buka messenger Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessenger();displayMessageComposer
Bagian berjudul “displayMessageComposer”Buka composer pesan dengan pesan yang sudah terisi.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayMessageComposer({ message: 'Hello from Capacitor' });displayHelpCenter
Bagian berjudul “displayHelpCenter”Buka help center Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayHelpCenter();hideMessenger
Bagian berjudul “hideMessenger”Sembunyikan messenger Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideMessenger();displayLauncher
Bagian berjudul “displayLauncher”Tampilkan tombol launcher Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayLauncher();hideLauncher
Bagian berjudul “hideLauncher”Sembunyikan tombol launcher Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideLauncher();displayInAppMessages
Bagian berjudul “displayInAppMessages”Aktifkan pesan in-app dari Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayInAppMessages();hideInAppMessages
Bagian berjudul “hideInAppMessages”Nonaktifkan pesan in-app dari Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.hideInAppMessages();displayCarousel
Bagian berjudul “displayCarousel”Tampilkan carousel Intercom tertentu.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayCarousel({ carouselId: 'carousel-id-123' });displayArticle
Bagian berjudul “displayArticle”Tampilkan artikel Intercom tertentu.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displayArticle({ articleId: 'article-id-123' });displaySurvey
Bagian berjudul “displaySurvey”Tampilkan survei Intercom tertentu.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.displaySurvey({ surveyId: 'survey-id-123' });setUserHash
Bagian berjudul “setUserHash”Atur HMAC untuk verifikasi identitas.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserHash({ hmac: 'hmac' });setUserJwt
Bagian berjudul “setUserJwt”Atur JWT untuk autentikasi messenger yang aman.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setUserJwt({ jwt: 'jwt' });setBottomPadding
Bagian berjudul “setBottomPadding”Atur padding bawah untuk UI messenger Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.setBottomPadding({ value: 1 });sendPushTokenToIntercom
Bagian berjudul “sendPushTokenToIntercom”Kirim token push notification ke Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.sendPushTokenToIntercom({ value: 'value' });receivePush
Bagian berjudul “receivePush”Tangani push notification Intercom yang diterima.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.receivePush({});getUnreadConversationCount
Bagian berjudul “getUnreadConversationCount”Dapatkan jumlah percakapan belum terbaca untuk pengguna saat ini.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
const result = await CapgoIntercom.getUnreadConversationCount();console.log(result);Referensi Tipe
Bagian berjudul “Referensi Tipe”IntercomLoadOptions
Bagian berjudul “IntercomLoadOptions”export interface IntercomLoadOptions { appId?: string; apiKeyIOS?: string; apiKeyAndroid?: string;}IntercomIdentifiedUserOptions
Bagian berjudul “IntercomIdentifiedUserOptions”export interface IntercomIdentifiedUserOptions { userId?: string; email?: string;}IntercomUserUpdateOptions
Bagian berjudul “IntercomUserUpdateOptions”export interface IntercomUserUpdateOptions { userId?: string; email?: string; name?: string; phone?: string; languageOverride?: string; customAttributes?: { [key: string]: any }; companies?: IntercomCompany[];}IntercomLogEventOptions
Bagian berjudul “IntercomLogEventOptions”export interface IntercomLogEventOptions { name: string; data?: { [key: string]: any };}IntercomMessageComposerOptions
Bagian berjudul “IntercomMessageComposerOptions”export interface IntercomMessageComposerOptions { message: string;}IntercomCarouselOptions
Bagian berjudul “IntercomCarouselOptions”export interface IntercomCarouselOptions { carouselId: string;}IntercomArticleOptions
Bagian berjudul “IntercomArticleOptions”export interface IntercomArticleOptions { articleId: string;}IntercomSurveyOptions
Bagian berjudul “IntercomSurveyOptions”export interface IntercomSurveyOptions { surveyId: string;}IntercomUserHashOptions
Bagian berjudul “IntercomUserHashOptions”export interface IntercomUserHashOptions { hmac: string;}IntercomUserJwtOptions
Bagian berjudul “IntercomUserJwtOptions”export interface IntercomUserJwtOptions { jwt: string;}IntercomBottomPaddingOptions
Bagian berjudul “IntercomBottomPaddingOptions”export interface IntercomBottomPaddingOptions { value: number;}IntercomPushTokenOptions
Bagian berjudul “IntercomPushTokenOptions”export interface IntercomPushTokenOptions { value: string;}Sumber Kebenaran
Bagian berjudul “Sumber Kebenaran”Halaman ini dibuat dari plugin src/definitions.ts. Jalankan ulang sync saat API publik berubah di upstream.
Lanjutkan dari Getting Started
Bagian berjudul “Lanjutkan dari Getting Started”Jika Anda menggunakan Panduan Memulai untuk merencanakan operasi dashboard dan API, hubungkan dengan Menggunakan @capgo/capacitor-intercom untuk kemampuan native di bagian Menggunakan @capgo/capacitor-intercom, Ringkasan API untuk detail implementasi di API Overview, Pendahuluan untuk detail implementasi di Introduction, Kunci API untuk detail implementasi di API Keys, dan Perangkat untuk detail implementasi di Devices.