Using @capgo/capacitor-intercom
Intercom Capacitor plugin.
Install
bun add @capgo/capacitor-intercom
bunx cap sync
bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.
Import
import { CapgoIntercom } from '@capgo/capacitor-intercom';
API at a glance
| Method | Description |
|---|---|
loadWithKeys |
Initialize Intercom with API keys at runtime. Use this if you prefer not to configure keys in capacitor.config. |
registerIdentifiedUser |
Register a known user with Intercom. At least one of userId or email must be provided. |
registerUnidentifiedUser |
Register an anonymous user with Intercom. |
updateUser |
Update user attributes in Intercom. |
logout |
Log the user out of Intercom. |
logEvent |
Log a custom event in Intercom. |
displayMessenger |
Open the Intercom messenger. |
displayMessageComposer |
Open the message composer with a pre-filled message. |
displayHelpCenter |
Open the Intercom help center. |
hideMessenger |
Hide the Intercom messenger. |
displayLauncher |
Show the Intercom launcher button. |
hideLauncher |
Hide the Intercom launcher button. |
displayInAppMessages |
Enable in-app messages from Intercom. |
hideInAppMessages |
Disable in-app messages from Intercom. |
displayCarousel |
Display a specific Intercom carousel. |
displayArticle |
Display a specific Intercom article. |
displaySurvey |
Display a specific Intercom survey. |
setUserHash |
Set the HMAC for identity verification. |
setUserJwt |
Set JWT for secure messenger authentication. |
setBottomPadding |
Set the bottom padding for the Intercom messenger UI. |
sendPushTokenToIntercom |
Send a push notification token to Intercom. |
receivePush |
Handle a received Intercom push notification. |
getUnreadConversationCount |
Get the number of unread conversations for the current user. |
Examples
loadWithKeys()
Initialize Intercom with API keys at runtime. Use this if you prefer not to configure keys 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()
Register a known user with Intercom. At least one of userId or email must be provided.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerIdentifiedUser({
userId: 'user-id-123',
email: 'user@example.com',
});
registerUnidentifiedUser()
Register an anonymous user with Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.registerUnidentifiedUser();
updateUser()
Update user attributes in Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.updateUser({ userId: 'user-id-123' });
logout()
Log the user out of Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logout();
logEvent()
Log a custom event in Intercom.
import { CapgoIntercom } from '@capgo/capacitor-intercom';
await CapgoIntercom.logEvent({ name: 'example' });
The table above lists the 23 core methods. Listener and version helpers, and the full contract of each method, are documented in the GitHub repository.
Listen to events
addListener returns a handle. Call handle.remove() when the screen unmounts, or CapgoIntercom.removeAllListeners() to clear every listener.
Full reference
Keep going from Using @capgo/capacitor-intercom
If you are using Using @capgo/capacitor-intercom to plan native plugin work, connect it with @capgo/capacitor-intercom for the implementation detail in @capgo/capacitor-intercom, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.