Home

Awesome

<p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p> <h3 align="center">Capacitor Intercom</h3> <p align="center"><strong><code>@capacitor-community/intercom</code></strong></p> <p align="center"> Capacitor community plugin for enabling Intercom capabilities </p> <p align="center"> <img src="https://img.shields.io/maintenance/yes/2024?style=flat-square" /> <a href="https://www.npmjs.com/package/@capacitor-community/intercom"><img src="https://img.shields.io/npm/l/@capacitor-community/intercom?style=flat-square" /></a> <br> <a href="https://www.npmjs.com/package/@capacitor-community/intercom"><img src="https://img.shields.io/npm/dw/@capacitor-community/intercom?style=flat-square" /></a> <a href="https://www.npmjs.com/package/@capacitor-community/intercom"><img src="https://img.shields.io/npm/v/@capacitor-community/intercom?style=flat-square" /></a> <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> <a href="#contributors"><img src="https://img.shields.io/badge/all%20contributors-20-orange?style=flat-square" /></a> <!-- ALL-CONTRIBUTORS-BADGE:END --> </p>

Sponsors

<table> <tr> <td align="center"> <a href="https://chatness.ai"> <img src="https://cdn.chatness.ai/images/logo-white-symbol.png" width="40" /> </a> </td> <td> <a href="https://chatness.ai"> Chatness AI </a> </td> </tr> </table>

Maintainers

MaintainerGitHubSocial
Stewan Silvastewones@stewones

Installation

Using npm:

npm install @capacitor-community/intercom

Using yarn:

yarn add @capacitor-community/intercom

Sync native files:

npx cap sync

Usage

import { Intercom } from '@capacitor-community/intercom';
import { PushNotifications } from '@capacitor/push-notifications';

// Register for push notifications from Intercom
PushNotifications.register();

// Register an indetified user
Intercom.registerIdentifiedUser({ userId: 123456 });
Intercom.registerIdentifiedUser({ email: 'test@example.com' });
Intercom.registerIdentifiedUser({ userId: 123456, email: 'test@example.com' });

// Register a log event
Intercom.logEvent({ name: 'my-event', data: { pi: 3.14 } });

// Display the message composer
Intercom.displayMessageComposer({ message: 'Hello there!' });

// Identity Verification
// https://developers.intercom.com/installing-intercom/docs/ios-identity-verification
Intercom.setUserHash({ hmac: 'xyz' });

iOS setup

{
 …
  "plugins": {
   "Intercom": {
      "iosApiKey": "ios_sdk-xxx",
      "iosAppId": "yyy"
    }
  }
…
}

Tip: every time you change a native code you may need to clean up the cache (Product > Clean build folder) and then run the app again.

Android setup

{
 …
  "plugins": {
   "Intercom": {
      "androidApiKey": "android_sdk-xxx",
      "androidAppId": "yyy"
    }
  }
…
}

Now you should be set to go. Try to run your client using ionic cap run android --livereload.

Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again.

API

<docgen-index> </docgen-index> <docgen-api> <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

loadWithKeys(...)

loadWithKeys(options: { appId?: string; apiKeyIOS?: string; apiKeyAndroid?: string; }) => Promise<void>
ParamType
options<code>{ appId?: string; apiKeyIOS?: string; apiKeyAndroid?: string; }</code>

registerIdentifiedUser(...)

registerIdentifiedUser(options: { userId?: string; email?: string; }) => Promise<void>
ParamType
options<code>{ userId?: string; email?: string; }</code>

registerUnidentifiedUser()

registerUnidentifiedUser() => Promise<void>

updateUser(...)

updateUser(options: IntercomUserUpdateOptions) => Promise<void>
ParamType
options<code><a href="#intercomuserupdateoptions">IntercomUserUpdateOptions</a></code>

logout()

logout() => Promise<void>

logEvent(...)

logEvent(options: { name: string; data?: any; }) => Promise<void>
ParamType
options<code>{ name: string; data?: any; }</code>

displayMessenger()

displayMessenger() => Promise<void>

displayMessageComposer(...)

displayMessageComposer(options: { message: string; }) => Promise<void>
ParamType
options<code>{ message: string; }</code>

displayHelpCenter()

displayHelpCenter() => Promise<void>

hideMessenger()

hideMessenger() => Promise<void>

displayLauncher()

displayLauncher() => Promise<void>

hideLauncher()

hideLauncher() => Promise<void>

displayInAppMessages()

displayInAppMessages() => Promise<void>

hideInAppMessages()

hideInAppMessages() => Promise<void>

displayCarousel(...)

displayCarousel(options: { carouselId: string; }) => Promise<void>
ParamType
options<code>{ carouselId: string; }</code>

setUserHash(...)

setUserHash(options: { hmac: string; }) => Promise<void>
ParamType
options<code>{ hmac: string; }</code>

setBottomPadding(...)

setBottomPadding(options: { value: string; }) => Promise<void>
ParamType
options<code>{ value: string; }</code>

sendPushTokenToIntercom(...)

sendPushTokenToIntercom(options: { value: string; }) => Promise<void>
ParamType
options<code>{ value: string; }</code>

receivePush(...)

receivePush(notification: IntercomPushNotificationData) => Promise<void>
ParamType
notification<code><a href="#intercompushnotificationdata">IntercomPushNotificationData</a></code>

displayArticle(...)

displayArticle(options: { articleId: string; }) => Promise<void>
ParamType
options<code>{ articleId: string; }</code>

addListener('windowDidShow', ...)

addListener(eventName: 'windowDidShow', listenerFunc: () => void) => Promise<PluginListenerHandle>
ParamType
eventName<code>'windowDidShow'</code>
listenerFunc<code>() => void</code>

Returns: <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>


addListener('windowDidHide', ...)

addListener(eventName: 'windowDidHide', listenerFunc: () => void) => Promise<PluginListenerHandle>
ParamType
eventName<code>'windowDidHide'</code>
listenerFunc<code>() => void</code>

Returns: <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>


removeAllListeners()

removeAllListeners() => Promise<void>

Interfaces

IntercomUserUpdateOptions

PropType
userId<code>string</code>
email<code>string</code>
name<code>string</code>
phone<code>string</code>
languageOverride<code>string</code>
customAttributes<code>{ [key: string]: any; }</code>

IntercomPushNotificationData

PropType
conversation_id<code>string</code>
message<code>string</code>
body<code>string</code>
author_name<code>string</code>
image_url<code>string</code>
app_name<code>string</code>
receiver<code>string</code>
conversation_part_type<code>string</code>
intercom_push_type<code>string</code>
uri<code>string</code>
push_only_conversation_id<code>string</code>
instance_id<code>string</code>
title<code>string</code>
priority<code>number</code>

PluginListenerHandle

PropType
remove<code>() => Promise<void></code>
</docgen-api>

Notice 🚀

We're starting fresh under an official org. If you were using the previous npm package capacitor-intercom, please update your package.json to @capacitor-community/intercom. Check out changelog for more info.

Breaking changes from Capacitor v2 to v3

 public class MainActivity extends BridgeActivity {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        // Initializes the Bridge
-        this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
-            // Additional plugins you've installed go here
-            add(IntercomPlugin.class);
-        }});
-    }
 }

License

MIT

Example

Contributors ✨

Thanks goes to these wonderful people (emoji key):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tr> <td align="center"><a href="https://twitter.com/stewones"><img src="https://avatars1.githubusercontent.com/u/719763?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Stew</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=stewones" title="Code">💻</a> <a href="https://github.com/capacitor-community/intercom/commits?author=stewones" title="Documentation">📖</a></td> <td align="center"><a href="https://davidseek.com/"><img src="https://avatars2.githubusercontent.com/u/17073950?v=4?s=75" width="75px;" alt=""/><br /><sub><b>David Seek</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=davidseek" title="Code">💻</a></td> <td align="center"><a href="https://github.com/rnikitin"><img src="https://avatars3.githubusercontent.com/u/1829318?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Roman Nikitin</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=rnikitin" title="Code">💻</a></td> <td align="center"><a href="https://github.com/atomassoni"><img src="https://avatars1.githubusercontent.com/u/17362459?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Anne Tomassoni</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=atomassoni" title="Code">💻</a> <a href="https://github.com/capacitor-community/intercom/pulls?q=is%3Apr+reviewed-by%3Aatomassoni" title="Reviewed Pull Requests">👀</a></td> <td align="center"><a href="https://github.com/mmodzelewski"><img src="https://avatars2.githubusercontent.com/u/7762633?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Maciej Modzelewski</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=mmodzelewski" title="Code">💻</a></td> <td align="center"><a href="https://github.com/spaghettiguru"><img src="https://avatars.githubusercontent.com/u/5624009?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Oleg Yuzvik</b></sub></a><br /><a href="#maintenance-spaghettiguru" title="Maintenance">🚧</a></td> <td align="center"><a href="https://github.com/gcorreaalves"><img src="https://avatars.githubusercontent.com/u/983426?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Gustavo Corrêa Alves</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=gcorreaalves" title="Documentation">📖</a></td> </tr> <tr> <td align="center"><a href="https://github.com/Jealvia"><img src="https://avatars.githubusercontent.com/u/28424830?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Jealvia</b></sub></a><br /><a href="#maintenance-Jealvia" title="Maintenance">🚧</a></td> <td align="center"><a href="https://adamduren.com/"><img src="https://avatars.githubusercontent.com/u/581097?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Adam Duren</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=adamduren" title="Code">💻</a> <a href="#maintenance-adamduren" title="Maintenance">🚧</a></td> <td align="center"><a href="https://github.com/ramikhafagi96"><img src="https://avatars.githubusercontent.com/u/38646828?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Rami Khafagi</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=ramikhafagi96" title="Code">💻</a></td> <td align="center"><a href="https://rdlabo.jp/"><img src="https://avatars.githubusercontent.com/u/9690024?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Masahiko Sakakibara</b></sub></a><br /><a href="#maintenance-rdlabo" title="Maintenance">🚧</a></td> <td align="center"><a href="https://github.com/camdjn"><img src="https://avatars.githubusercontent.com/u/7116085?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Dejardin Camille</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=camdjn" title="Code">💻</a></td> <td align="center"><a href="https://scr2em.github.io/portfolio/"><img src="https://avatars.githubusercontent.com/u/4671486?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Mohamed Abdelgwad</b></sub></a><br /><a href="#maintenance-scr2em" title="Maintenance">🚧</a></td> <td align="center"><a href="https://github.com/shark404"><img src="https://avatars.githubusercontent.com/u/4898049?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Nathan</b></sub></a><br /><a href="#maintenance-shark404" title="Maintenance">🚧</a></td> </tr> <tr> <td align="center"><a href="https://cwoebker.com/"><img src="https://avatars.githubusercontent.com/u/885085?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Cecil Wöbker</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=cwoebker" title="Code">💻</a> <a href="#maintenance-cwoebker" title="Maintenance">🚧</a></td> <td align="center"><a href="https://github.com/pavloPyrig0"><img src="https://avatars.githubusercontent.com/u/10965335?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Pavlo Pyrig</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=pavloPyrig0" title="Code">💻</a></td> <td align="center"><a href="https://github.com/dupiesdupreez"><img src="https://avatars.githubusercontent.com/u/6910085?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Ruan</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=dupiesdupreez" title="Code">💻</a></td> <td align="center"><a href="https://github.com/RickJeroen"><img src="https://avatars.githubusercontent.com/u/15357844?v=4?s=75" width="75px;" alt=""/><br /><sub><b>RickJeroen</b></sub></a><br /><a href="#maintenance-RickJeroen" title="Maintenance">🚧</a></td> <td align="center"><a href="https://t.me/reslear"><img src="https://avatars.githubusercontent.com/u/12596485?v=4?s=75" width="75px;" alt=""/><br /><sub><b>reslear</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=reslear" title="Documentation">📖</a></td> <td align="center"><a href="https://github.com/pmatter"><img src="https://avatars.githubusercontent.com/u/35367833?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Philipp Matter</b></sub></a><br /><a href="https://github.com/capacitor-community/intercom/commits?author=pmatter" title="Code">💻</a></td> </tr> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the all-contributors specification. Contributions of any kind welcome!