@capawesome/capacitor-intercom 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CapawesomeCapacitorIntercom.podspec +19 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +30 -0
  4. package/README.md +932 -0
  5. package/android/build.gradle +60 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/Intercom.java +441 -0
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/IntercomHelper.java +38 -0
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/IntercomPlugin.java +307 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/CustomException.java +20 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/CustomExceptions.java +23 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/events/UnreadConversationCountChangeEvent.java +22 -0
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/HandlePushNotificationOptions.java +25 -0
  14. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/InitializeOptions.java +34 -0
  15. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/IsIntercomPushNotificationOptions.java +25 -0
  16. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/LogEventOptions.java +35 -0
  17. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/LoginUserOptions.java +33 -0
  18. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/PresentContentOptions.java +71 -0
  19. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/PresentMessageComposerOptions.java +20 -0
  20. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/PresentOptions.java +19 -0
  21. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SendPushTokenToIntercomOptions.java +24 -0
  22. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SetBottomPaddingOptions.java +22 -0
  23. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SetInAppMessagesVisibleOptions.java +22 -0
  24. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SetLauncherVisibleOptions.java +22 -0
  25. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SetUserHashOptions.java +24 -0
  26. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SetUserJwtOptions.java +24 -0
  27. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/UpdateUserOptions.java +108 -0
  28. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/results/GetUnreadConversationCountResult.java +22 -0
  29. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/results/IsIntercomPushNotificationResult.java +22 -0
  30. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/interfaces/Callback.java +5 -0
  31. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/interfaces/EmptyCallback.java +5 -0
  32. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/interfaces/NonEmptyResultCallback.java +7 -0
  33. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/interfaces/Result.java +7 -0
  34. package/android/src/main/res/.gitkeep +0 -0
  35. package/dist/docs.json +1345 -0
  36. package/dist/esm/definitions.d.ts +549 -0
  37. package/dist/esm/definitions.js +27 -0
  38. package/dist/esm/definitions.js.map +1 -0
  39. package/dist/esm/index.d.ts +4 -0
  40. package/dist/esm/index.js +7 -0
  41. package/dist/esm/index.js.map +1 -0
  42. package/dist/esm/web.d.ts +34 -0
  43. package/dist/esm/web.js +175 -0
  44. package/dist/esm/web.js.map +1 -0
  45. package/dist/plugin.cjs.js +215 -0
  46. package/dist/plugin.cjs.js.map +1 -0
  47. package/dist/plugin.js +217 -0
  48. package/dist/plugin.js.map +1 -0
  49. package/ios/Plugin/Classes/Events/UnreadConversationCountChangeEvent.swift +16 -0
  50. package/ios/Plugin/Classes/Options/HandlePushNotificationOptions.swift +13 -0
  51. package/ios/Plugin/Classes/Options/InitializeOptions.swift +15 -0
  52. package/ios/Plugin/Classes/Options/IsIntercomPushNotificationOptions.swift +13 -0
  53. package/ios/Plugin/Classes/Options/LogEventOptions.swift +15 -0
  54. package/ios/Plugin/Classes/Options/LoginUserOptions.swift +17 -0
  55. package/ios/Plugin/Classes/Options/PresentContentOptions.swift +29 -0
  56. package/ios/Plugin/Classes/Options/PresentMessageComposerOptions.swift +10 -0
  57. package/ios/Plugin/Classes/Options/PresentOptions.swift +10 -0
  58. package/ios/Plugin/Classes/Options/SendPushTokenToIntercomOptions.swift +13 -0
  59. package/ios/Plugin/Classes/Options/SetBottomPaddingOptions.swift +13 -0
  60. package/ios/Plugin/Classes/Options/SetInAppMessagesVisibleOptions.swift +13 -0
  61. package/ios/Plugin/Classes/Options/SetLauncherVisibleOptions.swift +13 -0
  62. package/ios/Plugin/Classes/Options/SetUserHashOptions.swift +13 -0
  63. package/ios/Plugin/Classes/Options/SetUserJwtOptions.swift +13 -0
  64. package/ios/Plugin/Classes/Options/UpdateUserOptions.swift +38 -0
  65. package/ios/Plugin/Classes/Results/GetUnreadConversationCountResult.swift +16 -0
  66. package/ios/Plugin/Classes/Results/IsIntercomPushNotificationResult.swift +16 -0
  67. package/ios/Plugin/Enums/CustomError.swift +75 -0
  68. package/ios/Plugin/Info.plist +24 -0
  69. package/ios/Plugin/Intercom.swift +323 -0
  70. package/ios/Plugin/IntercomHelper.swift +17 -0
  71. package/ios/Plugin/IntercomPlugin.swift +261 -0
  72. package/ios/Plugin/Protocols/Result.swift +5 -0
  73. package/package.json +105 -0
package/README.md ADDED
@@ -0,0 +1,932 @@
1
+ # Capacitor Intercom Plugin
2
+
3
+ Unofficial Capacitor plugin for [Intercom](https://www.intercom.com/).[^1]
4
+
5
+ <div class="capawesome-z29o10a">
6
+ <a href="https://cloud.capawesome.io/" target="_blank">
7
+ <img alt="Deliver Live Updates to your Capacitor app with Capawesome Cloud" src="https://cloud.capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.png?t=1" />
8
+ </a>
9
+ </div>
10
+
11
+ ## Features
12
+
13
+ The Capacitor Intercom plugin is a modern integration of the Intercom SDKs for Capacitor apps. Here are some of the key features:
14
+
15
+ - 🖥️ **Cross-platform**: Supports Android, iOS, and Web.
16
+ - 💬 **Messenger**: Present the Intercom Messenger and its Home, Messages, Help Center, and Tickets spaces.
17
+ - 👤 **Identity**: Log in identified or unidentified users with the modern login APIs, wired to the native result callbacks.
18
+ - 🔐 **Identity Verification**: Verify the user's identity with a user hash (HMAC) or a JSON Web Token (JWT).
19
+ - 🧩 **User Attributes**: Update the user's name, email, phone, custom attributes, and companies.
20
+ - 📚 **Content**: Present articles, carousels, surveys, conversations, and help center collections.
21
+ - 🔢 **Unread Count**: Read the unread conversation count and listen for changes.
22
+ - 🔔 **Push Notifications**: Compose cleanly with Firebase Cloud Messaging (Android) and APNs (iOS).
23
+ - 🌐 **Typed Web SDK**: Uses the official `@intercom/messenger-js-sdk` package on the web.
24
+ - 📦 **CocoaPods & SPM**: Supports CocoaPods and Swift Package Manager for iOS.
25
+ - 🔁 **Up-to-date**: Always supports the latest Capacitor version.
26
+ - 🤝 **Compatibility**: Looking for a different chat SDK? Check out the [Crisp](https://capawesome.io/docs/sdks/capacitor/crisp/) plugin.
27
+
28
+ Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll take a look!
29
+
30
+ ## Use Cases
31
+
32
+ The Intercom plugin is typically used wherever you want to offer live chat and customer support inside your app, for example:
33
+
34
+ - **Customer support**: Let users chat with your support team directly from within the app.
35
+ - **User identification**: Attach the signed-in user's identity and attributes to every conversation.
36
+ - **Self-service**: Point users to articles, surveys, and help center collections without leaving the app.
37
+ - **Engagement**: Track events and show the unread conversation count in your own UI.
38
+ - **Re-engagement**: Notify users about new replies via push notifications.
39
+
40
+ ## Compatibility
41
+
42
+ | Plugin Version | Capacitor Version | Status |
43
+ | -------------- | ----------------- | -------------- |
44
+ | 0.x.x | >=8.x.x | Active support |
45
+
46
+ ## Installation
47
+
48
+ You can use our **AI-Assisted Setup** to install the plugin.
49
+ Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:
50
+
51
+ ```bash
52
+ npx skills add capawesome-team/skills --skill capacitor-plugins
53
+ ```
54
+
55
+ Then use the following prompt:
56
+
57
+ ```
58
+ Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-intercom` plugin in my project.
59
+ ```
60
+
61
+ If you prefer **Manual Setup**, install the plugin by running the following commands and follow the platform-specific instructions below:
62
+
63
+ ```bash
64
+ npm install @capawesome/capacitor-intercom
65
+ npx cap sync
66
+ ```
67
+
68
+ This plugin requires an [Intercom](https://www.intercom.com/) account. You can find your **App ID** and the platform-specific **API keys** in the Intercom dashboard under **Settings → Installation**.
69
+
70
+ ### Android
71
+
72
+ #### Variables
73
+
74
+ This plugin will use the following project variables (defined in your app's `variables.gradle` file):
75
+
76
+ - `$intercomSdkVersion` version of `io.intercom.android:intercom-sdk-base` (default: `18.4.0`)
77
+
78
+ This plugin depends on `intercom-sdk-base` (not the full `intercom-sdk` artifact) on purpose. The full artifact ships its own `FirebaseMessagingService` and automatically integrates Firebase Cloud Messaging, which conflicts with apps that manage push notifications themselves (e.g. via [`@capacitor-firebase/messaging`](https://github.com/capawesome-team/capacitor-firebase)). The base artifact leaves push handling to you (see below).
79
+
80
+ #### Push Notifications
81
+
82
+ Push notifications on Android are delivered through [Firebase Cloud Messaging (FCM)](https://firebase.google.com/docs/cloud-messaging). Because this plugin uses the base SDK, you forward the push token and incoming messages to Intercom from your JavaScript code. This is what makes the plugin coexist cleanly with [`@capacitor-firebase/messaging`](https://github.com/capawesome-team/capacitor-firebase):
83
+
84
+ ```typescript
85
+ import { FirebaseMessaging } from '@capacitor-firebase/messaging';
86
+ import { Intercom } from '@capawesome/capacitor-intercom';
87
+
88
+ // Forward the FCM token to Intercom.
89
+ FirebaseMessaging.addListener('tokenReceived', async ({ token }) => {
90
+ await Intercom.sendPushTokenToIntercom({ token });
91
+ });
92
+
93
+ // Forward incoming messages to Intercom.
94
+ FirebaseMessaging.addListener('notificationReceived', async ({ notification }) => {
95
+ const data = notification.data ?? {};
96
+ const { intercom } = await Intercom.isIntercomPushNotification({ data });
97
+ if (intercom) {
98
+ await Intercom.handlePushNotification({ data });
99
+ }
100
+ });
101
+ ```
102
+
103
+ ### iOS
104
+
105
+ The Intercom iOS SDK can be integrated via Swift Package Manager (recommended) or CocoaPods.
106
+
107
+ #### Info.plist
108
+
109
+ To manage push notifications yourself (and coexist with other push plugins), disable Intercom's automatic push integration by adding the following key to your `ios/App/App/Info.plist` file:
110
+
111
+ ```xml
112
+ <key>IntercomAutoIntegratePushNotifications</key>
113
+ <false/>
114
+ ```
115
+
116
+ #### Push Notifications
117
+
118
+ Push notifications on iOS are delivered through [Apple Push Notification service (APNs)](https://developer.apple.com/documentation/usernotifications):
119
+
120
+ 1. Enable the **Push Notifications** capability for your app target in Xcode.
121
+ 2. Register for remote notifications (e.g. via [`@capacitor-firebase/messaging`](https://github.com/capawesome-team/capacitor-firebase) or `@capacitor/push-notifications`).
122
+ 3. Forward the APNs device token to Intercom as a hexadecimal string:
123
+
124
+ ```typescript
125
+ import { PushNotifications } from '@capacitor/push-notifications';
126
+ import { Intercom } from '@capawesome/capacitor-intercom';
127
+
128
+ PushNotifications.addListener('registration', async ({ value }) => {
129
+ // `value` is the hexadecimal APNs device token on iOS.
130
+ await Intercom.sendPushTokenToIntercom({ token: value });
131
+ });
132
+ ```
133
+
134
+ You can then check and handle incoming notifications the same way as on Android using `isIntercomPushNotification(...)` and `handlePushNotification(...)`.
135
+
136
+ ### Web
137
+
138
+ The web implementation loads the Intercom Messenger from Intercom's CDN at runtime. This requires an active network connection. If your app enforces a [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP), make sure to allow the Intercom domains (e.g. `https://widget.intercom.io`, `https://js.intercomcdn.com`, and `wss://*.intercom.io`).
139
+
140
+ > [!NOTE]
141
+ > On the web, the Intercom launcher is visible by default after `initialize(...)`, whereas on Android and iOS it is hidden until you present the Messenger. Use `setLauncherVisible({ visible: false })` on the web if you want to match the mobile behavior.
142
+
143
+ ## Configuration
144
+
145
+ No configuration required for this plugin.
146
+
147
+ ## Usage
148
+
149
+ The following examples show how to use the plugin.
150
+
151
+ ### Initialize the plugin
152
+
153
+ Call `initialize(...)` once before all other methods:
154
+
155
+ ```typescript
156
+ import { Intercom } from '@capawesome/capacitor-intercom';
157
+
158
+ const initialize = async () => {
159
+ await Intercom.initialize({
160
+ appId: 'YOUR_APP_ID',
161
+ androidApiKey: 'YOUR_ANDROID_API_KEY',
162
+ iosApiKey: 'YOUR_IOS_API_KEY',
163
+ });
164
+ };
165
+ ```
166
+
167
+ ### Log in a user
168
+
169
+ Log in an identified user, optionally with identity verification:
170
+
171
+ ```typescript
172
+ import { Intercom } from '@capawesome/capacitor-intercom';
173
+
174
+ const loginUser = async () => {
175
+ await Intercom.setUserHash({ userHash: 'YOUR_HMAC_HASH' });
176
+ await Intercom.loginUser({
177
+ userId: 'jane-doe',
178
+ email: 'jane.doe@example.com',
179
+ });
180
+ };
181
+ ```
182
+
183
+ ### Update the user
184
+
185
+ Update the attributes of the current user:
186
+
187
+ ```typescript
188
+ import { Intercom } from '@capawesome/capacitor-intercom';
189
+
190
+ const updateUser = async () => {
191
+ await Intercom.updateUser({
192
+ name: 'Jane Doe',
193
+ customAttributes: { plan: 'pro' },
194
+ companies: [{ id: 'capawesome', name: 'Capawesome', plan: 'enterprise' }],
195
+ });
196
+ };
197
+ ```
198
+
199
+ ### Present the Messenger
200
+
201
+ Present the Intercom Messenger or a specific piece of content:
202
+
203
+ ```typescript
204
+ import { Intercom } from '@capawesome/capacitor-intercom';
205
+
206
+ const present = async () => {
207
+ await Intercom.present({ space: 'home' });
208
+ };
209
+
210
+ const presentArticle = async () => {
211
+ await Intercom.presentContent({ type: 'article', id: '123456' });
212
+ };
213
+ ```
214
+
215
+ ### Listen for events
216
+
217
+ Listen for the unread conversation count:
218
+
219
+ ```typescript
220
+ import { Intercom } from '@capawesome/capacitor-intercom';
221
+
222
+ const addListeners = async () => {
223
+ await Intercom.addListener('unreadConversationCountChange', ({ count }) => {
224
+ console.log('Unread conversations:', count);
225
+ });
226
+ };
227
+ ```
228
+
229
+ ## API
230
+
231
+ <docgen-index>
232
+
233
+ * [`getUnreadConversationCount()`](#getunreadconversationcount)
234
+ * [`handlePushNotification(...)`](#handlepushnotification)
235
+ * [`hide()`](#hide)
236
+ * [`initialize(...)`](#initialize)
237
+ * [`isIntercomPushNotification(...)`](#isintercompushnotification)
238
+ * [`logEvent(...)`](#logevent)
239
+ * [`loginUnidentifiedUser()`](#loginunidentifieduser)
240
+ * [`loginUser(...)`](#loginuser)
241
+ * [`logout()`](#logout)
242
+ * [`present(...)`](#present)
243
+ * [`presentContent(...)`](#presentcontent)
244
+ * [`presentMessageComposer(...)`](#presentmessagecomposer)
245
+ * [`sendPushTokenToIntercom(...)`](#sendpushtokentointercom)
246
+ * [`setBottomPadding(...)`](#setbottompadding)
247
+ * [`setInAppMessagesVisible(...)`](#setinappmessagesvisible)
248
+ * [`setLauncherVisible(...)`](#setlaunchervisible)
249
+ * [`setUserHash(...)`](#setuserhash)
250
+ * [`setUserJwt(...)`](#setuserjwt)
251
+ * [`updateUser(...)`](#updateuser)
252
+ * [`addListener('messengerHidden', ...)`](#addlistenermessengerhidden-)
253
+ * [`addListener('messengerShown', ...)`](#addlistenermessengershown-)
254
+ * [`addListener('unreadConversationCountChange', ...)`](#addlistenerunreadconversationcountchange-)
255
+ * [`removeAllListeners()`](#removealllisteners)
256
+ * [Interfaces](#interfaces)
257
+ * [Type Aliases](#type-aliases)
258
+
259
+ </docgen-index>
260
+
261
+ <docgen-api>
262
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
263
+
264
+ ### getUnreadConversationCount()
265
+
266
+ ```typescript
267
+ getUnreadConversationCount() => Promise<GetUnreadConversationCountResult>
268
+ ```
269
+
270
+ Get the number of unread conversations for the current user.
271
+
272
+ **Returns:** <code>Promise&lt;<a href="#getunreadconversationcountresult">GetUnreadConversationCountResult</a>&gt;</code>
273
+
274
+ **Since:** 0.1.0
275
+
276
+ --------------------
277
+
278
+
279
+ ### handlePushNotification(...)
280
+
281
+ ```typescript
282
+ handlePushNotification(options: HandlePushNotificationOptions) => Promise<void>
283
+ ```
284
+
285
+ Handle an incoming push notification that belongs to Intercom.
286
+
287
+ Use `isIntercomPushNotification(...)` to check whether the notification
288
+ belongs to Intercom before calling this method.
289
+
290
+ Only available on Android and iOS.
291
+
292
+ | Param | Type |
293
+ | ------------- | --------------------------------------------------------------------------------------- |
294
+ | **`options`** | <code><a href="#handlepushnotificationoptions">HandlePushNotificationOptions</a></code> |
295
+
296
+ **Since:** 0.1.0
297
+
298
+ --------------------
299
+
300
+
301
+ ### hide()
302
+
303
+ ```typescript
304
+ hide() => Promise<void>
305
+ ```
306
+
307
+ Hide any currently presented Intercom UI (e.g. the Messenger).
308
+
309
+ **Since:** 0.1.0
310
+
311
+ --------------------
312
+
313
+
314
+ ### initialize(...)
315
+
316
+ ```typescript
317
+ initialize(options: InitializeOptions) => Promise<void>
318
+ ```
319
+
320
+ Initialize the Intercom SDK with your app ID and API key.
321
+
322
+ This method must be called before any other method.
323
+
324
+ | Param | Type |
325
+ | ------------- | --------------------------------------------------------------- |
326
+ | **`options`** | <code><a href="#initializeoptions">InitializeOptions</a></code> |
327
+
328
+ **Since:** 0.1.0
329
+
330
+ --------------------
331
+
332
+
333
+ ### isIntercomPushNotification(...)
334
+
335
+ ```typescript
336
+ isIntercomPushNotification(options: IsIntercomPushNotificationOptions) => Promise<IsIntercomPushNotificationResult>
337
+ ```
338
+
339
+ Check whether an incoming push notification belongs to Intercom.
340
+
341
+ Only available on Android and iOS.
342
+
343
+ | Param | Type |
344
+ | ------------- | ----------------------------------------------------------------------------------------------- |
345
+ | **`options`** | <code><a href="#isintercompushnotificationoptions">IsIntercomPushNotificationOptions</a></code> |
346
+
347
+ **Returns:** <code>Promise&lt;<a href="#isintercompushnotificationresult">IsIntercomPushNotificationResult</a>&gt;</code>
348
+
349
+ **Since:** 0.1.0
350
+
351
+ --------------------
352
+
353
+
354
+ ### logEvent(...)
355
+
356
+ ```typescript
357
+ logEvent(options: LogEventOptions) => Promise<void>
358
+ ```
359
+
360
+ Log an event with an optional set of metadata.
361
+
362
+ | Param | Type |
363
+ | ------------- | ----------------------------------------------------------- |
364
+ | **`options`** | <code><a href="#logeventoptions">LogEventOptions</a></code> |
365
+
366
+ **Since:** 0.1.0
367
+
368
+ --------------------
369
+
370
+
371
+ ### loginUnidentifiedUser()
372
+
373
+ ```typescript
374
+ loginUnidentifiedUser() => Promise<void>
375
+ ```
376
+
377
+ Log in an unidentified (anonymous) user.
378
+
379
+ **Since:** 0.1.0
380
+
381
+ --------------------
382
+
383
+
384
+ ### loginUser(...)
385
+
386
+ ```typescript
387
+ loginUser(options: LoginUserOptions) => Promise<void>
388
+ ```
389
+
390
+ Log in an identified user with a user ID and/or an email address.
391
+
392
+ At least one of `userId` or `email` must be provided.
393
+
394
+ | Param | Type |
395
+ | ------------- | ------------------------------------------------------------- |
396
+ | **`options`** | <code><a href="#loginuseroptions">LoginUserOptions</a></code> |
397
+
398
+ **Since:** 0.1.0
399
+
400
+ --------------------
401
+
402
+
403
+ ### logout()
404
+
405
+ ```typescript
406
+ logout() => Promise<void>
407
+ ```
408
+
409
+ Log out the current user and clear the local Intercom data.
410
+
411
+ **Since:** 0.1.0
412
+
413
+ --------------------
414
+
415
+
416
+ ### present(...)
417
+
418
+ ```typescript
419
+ present(options?: PresentOptions | undefined) => Promise<void>
420
+ ```
421
+
422
+ Present the Intercom Messenger with the given space.
423
+
424
+ | Param | Type |
425
+ | ------------- | --------------------------------------------------------- |
426
+ | **`options`** | <code><a href="#presentoptions">PresentOptions</a></code> |
427
+
428
+ **Since:** 0.1.0
429
+
430
+ --------------------
431
+
432
+
433
+ ### presentContent(...)
434
+
435
+ ```typescript
436
+ presentContent(options: PresentContentOptions) => Promise<void>
437
+ ```
438
+
439
+ Present a specific piece of Intercom content (e.g. an article, carousel,
440
+ survey, or conversation).
441
+
442
+ | Param | Type |
443
+ | ------------- | ----------------------------------------------------------------------- |
444
+ | **`options`** | <code><a href="#presentcontentoptions">PresentContentOptions</a></code> |
445
+
446
+ **Since:** 0.1.0
447
+
448
+ --------------------
449
+
450
+
451
+ ### presentMessageComposer(...)
452
+
453
+ ```typescript
454
+ presentMessageComposer(options?: PresentMessageComposerOptions | undefined) => Promise<void>
455
+ ```
456
+
457
+ Present the Intercom message composer, optionally pre-filled with an
458
+ initial message.
459
+
460
+ | Param | Type |
461
+ | ------------- | --------------------------------------------------------------------------------------- |
462
+ | **`options`** | <code><a href="#presentmessagecomposeroptions">PresentMessageComposerOptions</a></code> |
463
+
464
+ **Since:** 0.1.0
465
+
466
+ --------------------
467
+
468
+
469
+ ### sendPushTokenToIntercom(...)
470
+
471
+ ```typescript
472
+ sendPushTokenToIntercom(options: SendPushTokenToIntercomOptions) => Promise<void>
473
+ ```
474
+
475
+ Forward a push notification token to Intercom.
476
+
477
+ On Android, pass the Firebase Cloud Messaging (FCM) token. On iOS, pass
478
+ the hexadecimal APNs device token.
479
+
480
+ | Param | Type |
481
+ | ------------- | ----------------------------------------------------------------------------------------- |
482
+ | **`options`** | <code><a href="#sendpushtokentointercomoptions">SendPushTokenToIntercomOptions</a></code> |
483
+
484
+ **Since:** 0.1.0
485
+
486
+ --------------------
487
+
488
+
489
+ ### setBottomPadding(...)
490
+
491
+ ```typescript
492
+ setBottomPadding(options: SetBottomPaddingOptions) => Promise<void>
493
+ ```
494
+
495
+ Set the bottom padding of the Intercom UI (in-app messages and launcher).
496
+
497
+ Only available on Android and iOS.
498
+
499
+ | Param | Type |
500
+ | ------------- | --------------------------------------------------------------------------- |
501
+ | **`options`** | <code><a href="#setbottompaddingoptions">SetBottomPaddingOptions</a></code> |
502
+
503
+ **Since:** 0.1.0
504
+
505
+ --------------------
506
+
507
+
508
+ ### setInAppMessagesVisible(...)
509
+
510
+ ```typescript
511
+ setInAppMessagesVisible(options: SetInAppMessagesVisibleOptions) => Promise<void>
512
+ ```
513
+
514
+ Set whether in-app messages are visible.
515
+
516
+ | Param | Type |
517
+ | ------------- | ----------------------------------------------------------------------------------------- |
518
+ | **`options`** | <code><a href="#setinappmessagesvisibleoptions">SetInAppMessagesVisibleOptions</a></code> |
519
+
520
+ **Since:** 0.1.0
521
+
522
+ --------------------
523
+
524
+
525
+ ### setLauncherVisible(...)
526
+
527
+ ```typescript
528
+ setLauncherVisible(options: SetLauncherVisibleOptions) => Promise<void>
529
+ ```
530
+
531
+ Set whether the Intercom launcher is visible.
532
+
533
+ | Param | Type |
534
+ | ------------- | ------------------------------------------------------------------------------- |
535
+ | **`options`** | <code><a href="#setlaunchervisibleoptions">SetLauncherVisibleOptions</a></code> |
536
+
537
+ **Since:** 0.1.0
538
+
539
+ --------------------
540
+
541
+
542
+ ### setUserHash(...)
543
+
544
+ ```typescript
545
+ setUserHash(options: SetUserHashOptions) => Promise<void>
546
+ ```
547
+
548
+ Set the user hash (HMAC) for identity verification.
549
+
550
+ This must be called before logging in the user.
551
+
552
+ | Param | Type |
553
+ | ------------- | ----------------------------------------------------------------- |
554
+ | **`options`** | <code><a href="#setuserhashoptions">SetUserHashOptions</a></code> |
555
+
556
+ **Since:** 0.1.0
557
+
558
+ --------------------
559
+
560
+
561
+ ### setUserJwt(...)
562
+
563
+ ```typescript
564
+ setUserJwt(options: SetUserJwtOptions) => Promise<void>
565
+ ```
566
+
567
+ Set the JSON Web Token (JWT) for identity verification.
568
+
569
+ This must be called before logging in the user.
570
+
571
+ | Param | Type |
572
+ | ------------- | --------------------------------------------------------------- |
573
+ | **`options`** | <code><a href="#setuserjwtoptions">SetUserJwtOptions</a></code> |
574
+
575
+ **Since:** 0.1.0
576
+
577
+ --------------------
578
+
579
+
580
+ ### updateUser(...)
581
+
582
+ ```typescript
583
+ updateUser(options: UpdateUserOptions) => Promise<void>
584
+ ```
585
+
586
+ Update the attributes of the current user.
587
+
588
+ | Param | Type |
589
+ | ------------- | --------------------------------------------------------------- |
590
+ | **`options`** | <code><a href="#updateuseroptions">UpdateUserOptions</a></code> |
591
+
592
+ **Since:** 0.1.0
593
+
594
+ --------------------
595
+
596
+
597
+ ### addListener('messengerHidden', ...)
598
+
599
+ ```typescript
600
+ addListener(eventName: 'messengerHidden', listenerFunc: () => void) => Promise<PluginListenerHandle>
601
+ ```
602
+
603
+ Called when the Intercom Messenger is hidden.
604
+
605
+ Only available on iOS and Web.
606
+
607
+ | Param | Type |
608
+ | ------------------ | ------------------------------ |
609
+ | **`eventName`** | <code>'messengerHidden'</code> |
610
+ | **`listenerFunc`** | <code>() =&gt; void</code> |
611
+
612
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
613
+
614
+ **Since:** 0.1.0
615
+
616
+ --------------------
617
+
618
+
619
+ ### addListener('messengerShown', ...)
620
+
621
+ ```typescript
622
+ addListener(eventName: 'messengerShown', listenerFunc: () => void) => Promise<PluginListenerHandle>
623
+ ```
624
+
625
+ Called when the Intercom Messenger is shown.
626
+
627
+ Only available on iOS and Web.
628
+
629
+ | Param | Type |
630
+ | ------------------ | ----------------------------- |
631
+ | **`eventName`** | <code>'messengerShown'</code> |
632
+ | **`listenerFunc`** | <code>() =&gt; void</code> |
633
+
634
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
635
+
636
+ **Since:** 0.1.0
637
+
638
+ --------------------
639
+
640
+
641
+ ### addListener('unreadConversationCountChange', ...)
642
+
643
+ ```typescript
644
+ addListener(eventName: 'unreadConversationCountChange', listenerFunc: (event: UnreadConversationCountChangeEvent) => void) => Promise<PluginListenerHandle>
645
+ ```
646
+
647
+ Called when the number of unread conversations changes.
648
+
649
+ | Param | Type |
650
+ | ------------------ | --------------------------------------------------------------------------------------------------------------------- |
651
+ | **`eventName`** | <code>'unreadConversationCountChange'</code> |
652
+ | **`listenerFunc`** | <code>(event: <a href="#unreadconversationcountchangeevent">UnreadConversationCountChangeEvent</a>) =&gt; void</code> |
653
+
654
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
655
+
656
+ **Since:** 0.1.0
657
+
658
+ --------------------
659
+
660
+
661
+ ### removeAllListeners()
662
+
663
+ ```typescript
664
+ removeAllListeners() => Promise<void>
665
+ ```
666
+
667
+ Remove all listeners for this plugin.
668
+
669
+ **Since:** 0.1.0
670
+
671
+ --------------------
672
+
673
+
674
+ ### Interfaces
675
+
676
+
677
+ #### GetUnreadConversationCountResult
678
+
679
+ | Prop | Type | Description | Since |
680
+ | ----------- | ------------------- | ----------------------------------- | ----- |
681
+ | **`count`** | <code>number</code> | The number of unread conversations. | 0.1.0 |
682
+
683
+
684
+ #### HandlePushNotificationOptions
685
+
686
+ | Prop | Type | Description | Since |
687
+ | ---------- | ------------------------------------------ | ---------------------------------- | ----- |
688
+ | **`data`** | <code>Record&lt;string, unknown&gt;</code> | The data of the push notification. | 0.1.0 |
689
+
690
+
691
+ #### InitializeOptions
692
+
693
+ | Prop | Type | Description | Since |
694
+ | ------------------- | ------------------- | -------------------------------------------------------------------------------- | ----- |
695
+ | **`androidApiKey`** | <code>string</code> | The Android API key of your Intercom app. Required to use the plugin on Android. | 0.1.0 |
696
+ | **`appId`** | <code>string</code> | The app ID of your Intercom app. | 0.1.0 |
697
+ | **`iosApiKey`** | <code>string</code> | The iOS API key of your Intercom app. Required to use the plugin on iOS. | 0.1.0 |
698
+
699
+
700
+ #### IsIntercomPushNotificationResult
701
+
702
+ | Prop | Type | Description | Since |
703
+ | -------------- | -------------------- | -------------------------------------------------- | ----- |
704
+ | **`intercom`** | <code>boolean</code> | Whether the push notification belongs to Intercom. | 0.1.0 |
705
+
706
+
707
+ #### IsIntercomPushNotificationOptions
708
+
709
+ | Prop | Type | Description | Since |
710
+ | ---------- | ------------------------------------------ | ---------------------------------- | ----- |
711
+ | **`data`** | <code>Record&lt;string, unknown&gt;</code> | The data of the push notification. | 0.1.0 |
712
+
713
+
714
+ #### LogEventOptions
715
+
716
+ | Prop | Type | Description | Since |
717
+ | ---------- | -------------------------------------------------------------- | -------------------------- | ----- |
718
+ | **`data`** | <code>Record&lt;string, string \| number \| boolean&gt;</code> | The metadata of the event. | 0.1.0 |
719
+ | **`name`** | <code>string</code> | The name of the event. | 0.1.0 |
720
+
721
+
722
+ #### LoginUserOptions
723
+
724
+ | Prop | Type | Description | Since |
725
+ | ------------ | ------------------- | ---------------------------------- | ----- |
726
+ | **`email`** | <code>string</code> | The email address of the user. | 0.1.0 |
727
+ | **`userId`** | <code>string</code> | The unique identifier of the user. | 0.1.0 |
728
+
729
+
730
+ #### PresentOptions
731
+
732
+ | Prop | Type | Description | Default | Since |
733
+ | ----------- | ------------------------------------------------------- | --------------------- | ------------------- | ----- |
734
+ | **`space`** | <code><a href="#intercomspace">IntercomSpace</a></code> | The space to present. | <code>'home'</code> | 0.1.0 |
735
+
736
+
737
+ #### PresentContentOptions
738
+
739
+ | Prop | Type | Description | Since |
740
+ | ---------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----- |
741
+ | **`id`** | <code>string</code> | The identifier of the content to present. Required for the `article`, `carousel`, `survey`, and `conversation` content types. | 0.1.0 |
742
+ | **`ids`** | <code>string[]</code> | The identifiers of the content to present. Required for the `help-center-collections` content type. | 0.1.0 |
743
+ | **`type`** | <code><a href="#intercomcontenttype">IntercomContentType</a></code> | The type of content to present. | 0.1.0 |
744
+
745
+
746
+ #### PresentMessageComposerOptions
747
+
748
+ | Prop | Type | Description | Since |
749
+ | -------------------- | ------------------- | ------------------------------------------ | ----- |
750
+ | **`initialMessage`** | <code>string</code> | The message to pre-fill the composer with. | 0.1.0 |
751
+
752
+
753
+ #### SendPushTokenToIntercomOptions
754
+
755
+ | Prop | Type | Description | Since |
756
+ | ----------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
757
+ | **`token`** | <code>string</code> | The push notification token. On Android, this is the Firebase Cloud Messaging (FCM) token. On iOS, this is the hexadecimal APNs device token. | 0.1.0 |
758
+
759
+
760
+ #### SetBottomPaddingOptions
761
+
762
+ | Prop | Type | Description | Since |
763
+ | ------------- | ------------------- | -------------------------- | ----- |
764
+ | **`padding`** | <code>number</code> | The bottom padding to set. | 0.1.0 |
765
+
766
+
767
+ #### SetInAppMessagesVisibleOptions
768
+
769
+ | Prop | Type | Description | Since |
770
+ | ------------- | -------------------- | ------------------------------------------ | ----- |
771
+ | **`visible`** | <code>boolean</code> | Whether in-app messages should be visible. | 0.1.0 |
772
+
773
+
774
+ #### SetLauncherVisibleOptions
775
+
776
+ | Prop | Type | Description | Since |
777
+ | ------------- | -------------------- | --------------------------------------- | ----- |
778
+ | **`visible`** | <code>boolean</code> | Whether the launcher should be visible. | 0.1.0 |
779
+
780
+
781
+ #### SetUserHashOptions
782
+
783
+ | Prop | Type | Description | Since |
784
+ | -------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
785
+ | **`userHash`** | <code>string</code> | The user hash (HMAC) for identity verification. The hash must be generated on your backend using your Intercom secret key. Never expose the secret key in your app. | 0.1.0 |
786
+
787
+
788
+ #### SetUserJwtOptions
789
+
790
+ | Prop | Type | Description | Since |
791
+ | --------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
792
+ | **`jwt`** | <code>string</code> | The JSON Web Token (JWT) for identity verification. The token must be generated on your backend using your Intercom secret key. Never expose the secret key in your app. | 0.1.0 |
793
+
794
+
795
+ #### UpdateUserOptions
796
+
797
+ | Prop | Type | Description | Since |
798
+ | ---------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------- | ----- |
799
+ | **`companies`** | <code>UpdateUserCompany[]</code> | The companies the user belongs to. | 0.1.0 |
800
+ | **`customAttributes`** | <code>Record&lt;string, string \| number \| boolean&gt;</code> | The custom attributes of the user. | 0.1.0 |
801
+ | **`email`** | <code>string</code> | The email address of the user. | 0.1.0 |
802
+ | **`languageOverride`** | <code>string</code> | The preferred language of the user as an ISO 639-1 code. | 0.1.0 |
803
+ | **`name`** | <code>string</code> | The name of the user. | 0.1.0 |
804
+ | **`phone`** | <code>string</code> | The phone number of the user. | 0.1.0 |
805
+ | **`signedUpAt`** | <code>number</code> | The date the user signed up as a Unix timestamp in seconds. | 0.1.0 |
806
+ | **`unsubscribedFromEmails`** | <code>boolean</code> | Whether the user is unsubscribed from emails. | 0.1.0 |
807
+ | **`userId`** | <code>string</code> | The unique identifier of the user. | 0.1.0 |
808
+
809
+
810
+ #### UpdateUserCompany
811
+
812
+ | Prop | Type | Description | Since |
813
+ | ---------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------- | ----- |
814
+ | **`createdAt`** | <code>number</code> | The date the company was created as a Unix timestamp in seconds. | 0.1.0 |
815
+ | **`customAttributes`** | <code>Record&lt;string, string \| number \| boolean&gt;</code> | The custom attributes of the company. | 0.1.0 |
816
+ | **`id`** | <code>string</code> | The unique identifier of the company. | 0.1.0 |
817
+ | **`monthlySpend`** | <code>number</code> | The monthly spend of the company. | 0.1.0 |
818
+ | **`name`** | <code>string</code> | The name of the company. | 0.1.0 |
819
+ | **`plan`** | <code>string</code> | The plan of the company. | 0.1.0 |
820
+
821
+
822
+ #### PluginListenerHandle
823
+
824
+ | Prop | Type |
825
+ | ------------ | ----------------------------------------- |
826
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
827
+
828
+
829
+ #### UnreadConversationCountChangeEvent
830
+
831
+ | Prop | Type | Description | Since |
832
+ | ----------- | ------------------- | ----------------------------------- | ----- |
833
+ | **`count`** | <code>number</code> | The number of unread conversations. | 0.1.0 |
834
+
835
+
836
+ ### Type Aliases
837
+
838
+
839
+ #### IntercomSpace
840
+
841
+ A space of the Intercom Messenger.
842
+
843
+ <code>'home' | 'messages' | 'help-center' | 'tickets'</code>
844
+
845
+
846
+ #### IntercomContentType
847
+
848
+ A type of Intercom content that can be presented.
849
+
850
+ <code>'article' | 'carousel' | 'conversation' | 'help-center-collections' | 'survey'</code>
851
+
852
+ </docgen-api>
853
+
854
+ ## Migration
855
+
856
+ If you are migrating from [`@capacitor-community/intercom`](https://github.com/capacitor-community/intercom) or another Intercom plugin, note that this plugin uses the **modern** Intercom API names throughout. The deprecated `register*` login methods are intentionally not exposed. The following table maps common legacy method names to their modern equivalents:
857
+
858
+ | Legacy method | This plugin |
859
+ | -------------------------- | ------------------------------------ |
860
+ | `registerIdentifiedUser` | `loginUser` |
861
+ | `registerUnidentifiedUser` | `loginUnidentifiedUser` |
862
+ | `logout` | `logout` |
863
+ | `displayMessenger` | `present` |
864
+ | `displayMessageComposer` | `presentMessageComposer` |
865
+ | `displayArticle` | `presentContent` |
866
+ | `displayCarousel` | `presentContent` |
867
+ | `displayHelpCenter` | `present({ space: 'help-center' })` |
868
+ | `hideMessenger` | `hide` |
869
+ | `unreadConversationCount` | `getUnreadConversationCount` |
870
+ | `setLauncherVisibility` | `setLauncherVisible` |
871
+ | `setInAppMessageVisibility`| `setInAppMessagesVisible` |
872
+ | `sendPushTokenToIntercom` | `sendPushTokenToIntercom` |
873
+
874
+ ## Platform Support
875
+
876
+ Not every Intercom SDK feature is available on all platforms. The following table lists the notable per-platform differences of the plugin's API:
877
+
878
+ | Method / Event | Android | iOS | Web |
879
+ | ------------------------------------------------- | :-----: | :-: | :-: |
880
+ | `handlePushNotification(...)` | ✅ | ✅ | ❌ |
881
+ | `isIntercomPushNotification(...)` | ✅ | ✅ | ❌ |
882
+ | `presentContent(...)` (`carousel`) | ✅ | ✅ | ❌ |
883
+ | `presentContent(...)` (`help-center-collections`) | ✅ | ✅ | ❌ |
884
+ | `sendPushTokenToIntercom(...)` | ✅ | ✅ | ❌ |
885
+ | `setBottomPadding(...)` | ✅ | ✅ | ❌ |
886
+ | `messengerShown` / `messengerHidden` events | ❌ | ✅ | ✅ |
887
+
888
+ Additional notes:
889
+
890
+ - On the web, `getUnreadConversationCount(...)` returns the last value received from the change event, since the web SDK exposes the count only through a callback.
891
+ - The `messengerShown` and `messengerHidden` events are not available on Android because the Intercom Android SDK does not expose a window visibility hook.
892
+ - `setBottomPadding(...)` uses pixels on Android and points on iOS, matching the respective native SDK.
893
+
894
+ ## Licensing
895
+
896
+ The Intercom Android and iOS SDKs are licensed under the Apache License 2.0 and are distributed via Maven Central, CocoaPods, and Swift Package Manager. The web SDK is licensed under the MIT license. This plugin only declares these SDKs as dependencies and does not bundle or modify them. Using the plugin requires an active Intercom account. The MIT license of this plugin covers the wrapper code only, not the Intercom SDKs.
897
+
898
+ ## FAQ
899
+
900
+ ### Do I need an Intercom account to use this plugin?
901
+
902
+ Yes. This plugin wraps the official Intercom SDKs, which require an active [Intercom](https://www.intercom.com/) account, an app ID, and platform-specific API keys.
903
+
904
+ ### How is this plugin different from other similar plugins?
905
+
906
+ This plugin uses Intercom's modern login APIs (`loginUnidentifiedUser(...)` and `loginUser(...)`). On Android it depends on the base SDK, so it coexists cleanly with your own Firebase Cloud Messaging or APNs setup and lets you forward push notifications to Intercom yourself. It also ships a fully typed web implementation, cross-platform push notification helpers, and is backed by dedicated support.
907
+
908
+ ### Why does this plugin use `intercom-sdk-base` instead of `intercom-sdk` on Android?
909
+
910
+ The full `intercom-sdk` artifact automatically integrates Firebase Cloud Messaging by registering its own `FirebaseMessagingService`. This conflicts with apps that manage push notifications themselves (e.g. via `@capacitor-firebase/messaging`). The base artifact avoids this conflict and lets you forward push notifications to Intercom yourself.
911
+
912
+ ### How does identity verification work?
913
+
914
+ Generate a user hash (HMAC) or a JSON Web Token (JWT) on your backend using your Intercom secret key, then pass it via `setUserHash(...)` or `setUserJwt(...)` **before** logging in the user. Never expose your secret key in your app.
915
+
916
+ ### Can I use this plugin with Ionic, React, Vue or Angular?
917
+
918
+ Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.
919
+
920
+ ## Newsletter
921
+
922
+ Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
923
+
924
+ ## Changelog
925
+
926
+ See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/intercom/CHANGELOG.md).
927
+
928
+ ## License
929
+
930
+ See [LICENSE](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/intercom/LICENSE).
931
+
932
+ [^1]: This project is not affiliated with, endorsed by, sponsored by, or approved by Intercom Inc. or any of its affiliates or subsidiaries. "Intercom" is a trademark of Intercom Inc.