@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
@@ -0,0 +1,549 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ export interface IntercomPlugin {
3
+ /**
4
+ * Get the number of unread conversations for the current user.
5
+ *
6
+ * @since 0.1.0
7
+ */
8
+ getUnreadConversationCount(): Promise<GetUnreadConversationCountResult>;
9
+ /**
10
+ * Handle an incoming push notification that belongs to Intercom.
11
+ *
12
+ * Use `isIntercomPushNotification(...)` to check whether the notification
13
+ * belongs to Intercom before calling this method.
14
+ *
15
+ * Only available on Android and iOS.
16
+ *
17
+ * @since 0.1.0
18
+ */
19
+ handlePushNotification(options: HandlePushNotificationOptions): Promise<void>;
20
+ /**
21
+ * Hide any currently presented Intercom UI (e.g. the Messenger).
22
+ *
23
+ * @since 0.1.0
24
+ */
25
+ hide(): Promise<void>;
26
+ /**
27
+ * Initialize the Intercom SDK with your app ID and API key.
28
+ *
29
+ * This method must be called before any other method.
30
+ *
31
+ * @since 0.1.0
32
+ */
33
+ initialize(options: InitializeOptions): Promise<void>;
34
+ /**
35
+ * Check whether an incoming push notification belongs to Intercom.
36
+ *
37
+ * Only available on Android and iOS.
38
+ *
39
+ * @since 0.1.0
40
+ */
41
+ isIntercomPushNotification(options: IsIntercomPushNotificationOptions): Promise<IsIntercomPushNotificationResult>;
42
+ /**
43
+ * Log an event with an optional set of metadata.
44
+ *
45
+ * @since 0.1.0
46
+ */
47
+ logEvent(options: LogEventOptions): Promise<void>;
48
+ /**
49
+ * Log in an unidentified (anonymous) user.
50
+ *
51
+ * @since 0.1.0
52
+ */
53
+ loginUnidentifiedUser(): Promise<void>;
54
+ /**
55
+ * Log in an identified user with a user ID and/or an email address.
56
+ *
57
+ * At least one of `userId` or `email` must be provided.
58
+ *
59
+ * @since 0.1.0
60
+ */
61
+ loginUser(options: LoginUserOptions): Promise<void>;
62
+ /**
63
+ * Log out the current user and clear the local Intercom data.
64
+ *
65
+ * @since 0.1.0
66
+ */
67
+ logout(): Promise<void>;
68
+ /**
69
+ * Present the Intercom Messenger with the given space.
70
+ *
71
+ * @since 0.1.0
72
+ */
73
+ present(options?: PresentOptions): Promise<void>;
74
+ /**
75
+ * Present a specific piece of Intercom content (e.g. an article, carousel,
76
+ * survey, or conversation).
77
+ *
78
+ * @since 0.1.0
79
+ */
80
+ presentContent(options: PresentContentOptions): Promise<void>;
81
+ /**
82
+ * Present the Intercom message composer, optionally pre-filled with an
83
+ * initial message.
84
+ *
85
+ * @since 0.1.0
86
+ */
87
+ presentMessageComposer(options?: PresentMessageComposerOptions): Promise<void>;
88
+ /**
89
+ * Forward a push notification token to Intercom.
90
+ *
91
+ * On Android, pass the Firebase Cloud Messaging (FCM) token. On iOS, pass
92
+ * the hexadecimal APNs device token.
93
+ *
94
+ * @since 0.1.0
95
+ */
96
+ sendPushTokenToIntercom(options: SendPushTokenToIntercomOptions): Promise<void>;
97
+ /**
98
+ * Set the bottom padding of the Intercom UI (in-app messages and launcher).
99
+ *
100
+ * Only available on Android and iOS.
101
+ *
102
+ * @since 0.1.0
103
+ */
104
+ setBottomPadding(options: SetBottomPaddingOptions): Promise<void>;
105
+ /**
106
+ * Set whether in-app messages are visible.
107
+ *
108
+ * @since 0.1.0
109
+ */
110
+ setInAppMessagesVisible(options: SetInAppMessagesVisibleOptions): Promise<void>;
111
+ /**
112
+ * Set whether the Intercom launcher is visible.
113
+ *
114
+ * @since 0.1.0
115
+ */
116
+ setLauncherVisible(options: SetLauncherVisibleOptions): Promise<void>;
117
+ /**
118
+ * Set the user hash (HMAC) for identity verification.
119
+ *
120
+ * This must be called before logging in the user.
121
+ *
122
+ * @since 0.1.0
123
+ */
124
+ setUserHash(options: SetUserHashOptions): Promise<void>;
125
+ /**
126
+ * Set the JSON Web Token (JWT) for identity verification.
127
+ *
128
+ * This must be called before logging in the user.
129
+ *
130
+ * @since 0.1.0
131
+ */
132
+ setUserJwt(options: SetUserJwtOptions): Promise<void>;
133
+ /**
134
+ * Update the attributes of the current user.
135
+ *
136
+ * @since 0.1.0
137
+ */
138
+ updateUser(options: UpdateUserOptions): Promise<void>;
139
+ /**
140
+ * Called when the Intercom Messenger is hidden.
141
+ *
142
+ * Only available on iOS and Web.
143
+ *
144
+ * @since 0.1.0
145
+ */
146
+ addListener(eventName: 'messengerHidden', listenerFunc: () => void): Promise<PluginListenerHandle>;
147
+ /**
148
+ * Called when the Intercom Messenger is shown.
149
+ *
150
+ * Only available on iOS and Web.
151
+ *
152
+ * @since 0.1.0
153
+ */
154
+ addListener(eventName: 'messengerShown', listenerFunc: () => void): Promise<PluginListenerHandle>;
155
+ /**
156
+ * Called when the number of unread conversations changes.
157
+ *
158
+ * @since 0.1.0
159
+ */
160
+ addListener(eventName: 'unreadConversationCountChange', listenerFunc: (event: UnreadConversationCountChangeEvent) => void): Promise<PluginListenerHandle>;
161
+ /**
162
+ * Remove all listeners for this plugin.
163
+ *
164
+ * @since 0.1.0
165
+ */
166
+ removeAllListeners(): Promise<void>;
167
+ }
168
+ /**
169
+ * @since 0.1.0
170
+ */
171
+ export interface GetUnreadConversationCountResult {
172
+ /**
173
+ * The number of unread conversations.
174
+ *
175
+ * @since 0.1.0
176
+ */
177
+ count: number;
178
+ }
179
+ /**
180
+ * @since 0.1.0
181
+ */
182
+ export interface HandlePushNotificationOptions {
183
+ /**
184
+ * The data of the push notification.
185
+ *
186
+ * @since 0.1.0
187
+ */
188
+ data: Record<string, unknown>;
189
+ }
190
+ /**
191
+ * @since 0.1.0
192
+ */
193
+ export interface InitializeOptions {
194
+ /**
195
+ * The Android API key of your Intercom app.
196
+ *
197
+ * Required to use the plugin on Android.
198
+ *
199
+ * @since 0.1.0
200
+ */
201
+ androidApiKey?: string;
202
+ /**
203
+ * The app ID of your Intercom app.
204
+ *
205
+ * @since 0.1.0
206
+ */
207
+ appId: string;
208
+ /**
209
+ * The iOS API key of your Intercom app.
210
+ *
211
+ * Required to use the plugin on iOS.
212
+ *
213
+ * @since 0.1.0
214
+ */
215
+ iosApiKey?: string;
216
+ }
217
+ /**
218
+ * @since 0.1.0
219
+ */
220
+ export interface IsIntercomPushNotificationOptions {
221
+ /**
222
+ * The data of the push notification.
223
+ *
224
+ * @since 0.1.0
225
+ */
226
+ data: Record<string, unknown>;
227
+ }
228
+ /**
229
+ * @since 0.1.0
230
+ */
231
+ export interface IsIntercomPushNotificationResult {
232
+ /**
233
+ * Whether the push notification belongs to Intercom.
234
+ *
235
+ * @since 0.1.0
236
+ */
237
+ intercom: boolean;
238
+ }
239
+ /**
240
+ * @since 0.1.0
241
+ */
242
+ export interface LogEventOptions {
243
+ /**
244
+ * The metadata of the event.
245
+ *
246
+ * @since 0.1.0
247
+ */
248
+ data?: Record<string, string | number | boolean>;
249
+ /**
250
+ * The name of the event.
251
+ *
252
+ * @since 0.1.0
253
+ */
254
+ name: string;
255
+ }
256
+ /**
257
+ * @since 0.1.0
258
+ */
259
+ export interface LoginUserOptions {
260
+ /**
261
+ * The email address of the user.
262
+ *
263
+ * @since 0.1.0
264
+ */
265
+ email?: string;
266
+ /**
267
+ * The unique identifier of the user.
268
+ *
269
+ * @since 0.1.0
270
+ */
271
+ userId?: string;
272
+ }
273
+ /**
274
+ * @since 0.1.0
275
+ */
276
+ export interface PresentContentOptions {
277
+ /**
278
+ * The identifier of the content to present.
279
+ *
280
+ * Required for the `article`, `carousel`, `survey`, and `conversation`
281
+ * content types.
282
+ *
283
+ * @since 0.1.0
284
+ */
285
+ id?: string;
286
+ /**
287
+ * The identifiers of the content to present.
288
+ *
289
+ * Required for the `help-center-collections` content type.
290
+ *
291
+ * @since 0.1.0
292
+ */
293
+ ids?: string[];
294
+ /**
295
+ * The type of content to present.
296
+ *
297
+ * @since 0.1.0
298
+ */
299
+ type: IntercomContentType;
300
+ }
301
+ /**
302
+ * @since 0.1.0
303
+ */
304
+ export interface PresentMessageComposerOptions {
305
+ /**
306
+ * The message to pre-fill the composer with.
307
+ *
308
+ * @since 0.1.0
309
+ */
310
+ initialMessage?: string;
311
+ }
312
+ /**
313
+ * @since 0.1.0
314
+ */
315
+ export interface PresentOptions {
316
+ /**
317
+ * The space to present.
318
+ *
319
+ * @default 'home'
320
+ * @since 0.1.0
321
+ */
322
+ space?: IntercomSpace;
323
+ }
324
+ /**
325
+ * @since 0.1.0
326
+ */
327
+ export interface SendPushTokenToIntercomOptions {
328
+ /**
329
+ * The push notification token.
330
+ *
331
+ * On Android, this is the Firebase Cloud Messaging (FCM) token. On iOS,
332
+ * this is the hexadecimal APNs device token.
333
+ *
334
+ * @since 0.1.0
335
+ */
336
+ token: string;
337
+ }
338
+ /**
339
+ * @since 0.1.0
340
+ */
341
+ export interface SetBottomPaddingOptions {
342
+ /**
343
+ * The bottom padding to set.
344
+ *
345
+ * @since 0.1.0
346
+ */
347
+ padding: number;
348
+ }
349
+ /**
350
+ * @since 0.1.0
351
+ */
352
+ export interface SetInAppMessagesVisibleOptions {
353
+ /**
354
+ * Whether in-app messages should be visible.
355
+ *
356
+ * @since 0.1.0
357
+ */
358
+ visible: boolean;
359
+ }
360
+ /**
361
+ * @since 0.1.0
362
+ */
363
+ export interface SetLauncherVisibleOptions {
364
+ /**
365
+ * Whether the launcher should be visible.
366
+ *
367
+ * @since 0.1.0
368
+ */
369
+ visible: boolean;
370
+ }
371
+ /**
372
+ * @since 0.1.0
373
+ */
374
+ export interface SetUserHashOptions {
375
+ /**
376
+ * The user hash (HMAC) for identity verification.
377
+ *
378
+ * The hash must be generated on your backend using your Intercom secret
379
+ * key. Never expose the secret key in your app.
380
+ *
381
+ * @since 0.1.0
382
+ */
383
+ userHash: string;
384
+ }
385
+ /**
386
+ * @since 0.1.0
387
+ */
388
+ export interface SetUserJwtOptions {
389
+ /**
390
+ * The JSON Web Token (JWT) for identity verification.
391
+ *
392
+ * The token must be generated on your backend using your Intercom secret
393
+ * key. Never expose the secret key in your app.
394
+ *
395
+ * @since 0.1.0
396
+ */
397
+ jwt: string;
398
+ }
399
+ /**
400
+ * @since 0.1.0
401
+ */
402
+ export interface UnreadConversationCountChangeEvent {
403
+ /**
404
+ * The number of unread conversations.
405
+ *
406
+ * @since 0.1.0
407
+ */
408
+ count: number;
409
+ }
410
+ /**
411
+ * @since 0.1.0
412
+ */
413
+ export interface UpdateUserCompany {
414
+ /**
415
+ * The date the company was created as a Unix timestamp in seconds.
416
+ *
417
+ * @since 0.1.0
418
+ * @example 1704067200
419
+ */
420
+ createdAt?: number;
421
+ /**
422
+ * The custom attributes of the company.
423
+ *
424
+ * @since 0.1.0
425
+ */
426
+ customAttributes?: Record<string, string | number | boolean>;
427
+ /**
428
+ * The unique identifier of the company.
429
+ *
430
+ * @since 0.1.0
431
+ */
432
+ id: string;
433
+ /**
434
+ * The monthly spend of the company.
435
+ *
436
+ * @since 0.1.0
437
+ */
438
+ monthlySpend?: number;
439
+ /**
440
+ * The name of the company.
441
+ *
442
+ * @since 0.1.0
443
+ */
444
+ name?: string;
445
+ /**
446
+ * The plan of the company.
447
+ *
448
+ * @since 0.1.0
449
+ */
450
+ plan?: string;
451
+ }
452
+ /**
453
+ * @since 0.1.0
454
+ */
455
+ export interface UpdateUserOptions {
456
+ /**
457
+ * The companies the user belongs to.
458
+ *
459
+ * @since 0.1.0
460
+ */
461
+ companies?: UpdateUserCompany[];
462
+ /**
463
+ * The custom attributes of the user.
464
+ *
465
+ * @since 0.1.0
466
+ */
467
+ customAttributes?: Record<string, string | number | boolean>;
468
+ /**
469
+ * The email address of the user.
470
+ *
471
+ * @since 0.1.0
472
+ */
473
+ email?: string;
474
+ /**
475
+ * The preferred language of the user as an ISO 639-1 code.
476
+ *
477
+ * @since 0.1.0
478
+ * @example 'en'
479
+ */
480
+ languageOverride?: string;
481
+ /**
482
+ * The name of the user.
483
+ *
484
+ * @since 0.1.0
485
+ */
486
+ name?: string;
487
+ /**
488
+ * The phone number of the user.
489
+ *
490
+ * @since 0.1.0
491
+ */
492
+ phone?: string;
493
+ /**
494
+ * The date the user signed up as a Unix timestamp in seconds.
495
+ *
496
+ * @since 0.1.0
497
+ * @example 1704067200
498
+ */
499
+ signedUpAt?: number;
500
+ /**
501
+ * Whether the user is unsubscribed from emails.
502
+ *
503
+ * @since 0.1.0
504
+ */
505
+ unsubscribedFromEmails?: boolean;
506
+ /**
507
+ * The unique identifier of the user.
508
+ *
509
+ * @since 0.1.0
510
+ */
511
+ userId?: string;
512
+ }
513
+ /**
514
+ * A type of Intercom content that can be presented.
515
+ *
516
+ * @since 0.1.0
517
+ */
518
+ export type IntercomContentType = 'article' | 'carousel' | 'conversation' | 'help-center-collections' | 'survey';
519
+ /**
520
+ * A space of the Intercom Messenger.
521
+ *
522
+ * @since 0.1.0
523
+ */
524
+ export type IntercomSpace = 'home' | 'messages' | 'help-center' | 'tickets';
525
+ /**
526
+ * @since 0.1.0
527
+ */
528
+ export declare enum ErrorCode {
529
+ /**
530
+ * The login of the user failed.
531
+ *
532
+ * @since 0.1.0
533
+ */
534
+ LoginFailed = "LOGIN_FAILED",
535
+ /**
536
+ * The plugin has not been initialized yet.
537
+ *
538
+ * Call `initialize(...)` before calling any other method.
539
+ *
540
+ * @since 0.1.0
541
+ */
542
+ NotInitialized = "NOT_INITIALIZED",
543
+ /**
544
+ * The update of the user failed.
545
+ *
546
+ * @since 0.1.0
547
+ */
548
+ UpdateFailed = "UPDATE_FAILED"
549
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @since 0.1.0
3
+ */
4
+ export var ErrorCode;
5
+ (function (ErrorCode) {
6
+ /**
7
+ * The login of the user failed.
8
+ *
9
+ * @since 0.1.0
10
+ */
11
+ ErrorCode["LoginFailed"] = "LOGIN_FAILED";
12
+ /**
13
+ * The plugin has not been initialized yet.
14
+ *
15
+ * Call `initialize(...)` before calling any other method.
16
+ *
17
+ * @since 0.1.0
18
+ */
19
+ ErrorCode["NotInitialized"] = "NOT_INITIALIZED";
20
+ /**
21
+ * The update of the user failed.
22
+ *
23
+ * @since 0.1.0
24
+ */
25
+ ErrorCode["UpdateFailed"] = "UPDATE_FAILED";
26
+ })(ErrorCode || (ErrorCode = {}));
27
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAyjBA;;GAEG;AACH,MAAM,CAAN,IAAY,SAqBX;AArBD,WAAY,SAAS;IACnB;;;;OAIG;IACH,yCAA4B,CAAA;IAC5B;;;;;;OAMG;IACH,+CAAkC,CAAA;IAClC;;;;OAIG;IACH,2CAA8B,CAAA;AAChC,CAAC,EArBW,SAAS,KAAT,SAAS,QAqBpB","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface IntercomPlugin {\n /**\n * Get the number of unread conversations for the current user.\n *\n * @since 0.1.0\n */\n getUnreadConversationCount(): Promise<GetUnreadConversationCountResult>;\n /**\n * Handle an incoming push notification that belongs to Intercom.\n *\n * Use `isIntercomPushNotification(...)` to check whether the notification\n * belongs to Intercom before calling this method.\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n handlePushNotification(options: HandlePushNotificationOptions): Promise<void>;\n /**\n * Hide any currently presented Intercom UI (e.g. the Messenger).\n *\n * @since 0.1.0\n */\n hide(): Promise<void>;\n /**\n * Initialize the Intercom SDK with your app ID and API key.\n *\n * This method must be called before any other method.\n *\n * @since 0.1.0\n */\n initialize(options: InitializeOptions): Promise<void>;\n /**\n * Check whether an incoming push notification belongs to Intercom.\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n isIntercomPushNotification(\n options: IsIntercomPushNotificationOptions,\n ): Promise<IsIntercomPushNotificationResult>;\n /**\n * Log an event with an optional set of metadata.\n *\n * @since 0.1.0\n */\n logEvent(options: LogEventOptions): Promise<void>;\n /**\n * Log in an unidentified (anonymous) user.\n *\n * @since 0.1.0\n */\n loginUnidentifiedUser(): Promise<void>;\n /**\n * Log in an identified user with a user ID and/or an email address.\n *\n * At least one of `userId` or `email` must be provided.\n *\n * @since 0.1.0\n */\n loginUser(options: LoginUserOptions): Promise<void>;\n /**\n * Log out the current user and clear the local Intercom data.\n *\n * @since 0.1.0\n */\n logout(): Promise<void>;\n /**\n * Present the Intercom Messenger with the given space.\n *\n * @since 0.1.0\n */\n present(options?: PresentOptions): Promise<void>;\n /**\n * Present a specific piece of Intercom content (e.g. an article, carousel,\n * survey, or conversation).\n *\n * @since 0.1.0\n */\n presentContent(options: PresentContentOptions): Promise<void>;\n /**\n * Present the Intercom message composer, optionally pre-filled with an\n * initial message.\n *\n * @since 0.1.0\n */\n presentMessageComposer(\n options?: PresentMessageComposerOptions,\n ): Promise<void>;\n /**\n * Forward a push notification token to Intercom.\n *\n * On Android, pass the Firebase Cloud Messaging (FCM) token. On iOS, pass\n * the hexadecimal APNs device token.\n *\n * @since 0.1.0\n */\n sendPushTokenToIntercom(\n options: SendPushTokenToIntercomOptions,\n ): Promise<void>;\n /**\n * Set the bottom padding of the Intercom UI (in-app messages and launcher).\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n setBottomPadding(options: SetBottomPaddingOptions): Promise<void>;\n /**\n * Set whether in-app messages are visible.\n *\n * @since 0.1.0\n */\n setInAppMessagesVisible(\n options: SetInAppMessagesVisibleOptions,\n ): Promise<void>;\n /**\n * Set whether the Intercom launcher is visible.\n *\n * @since 0.1.0\n */\n setLauncherVisible(options: SetLauncherVisibleOptions): Promise<void>;\n /**\n * Set the user hash (HMAC) for identity verification.\n *\n * This must be called before logging in the user.\n *\n * @since 0.1.0\n */\n setUserHash(options: SetUserHashOptions): Promise<void>;\n /**\n * Set the JSON Web Token (JWT) for identity verification.\n *\n * This must be called before logging in the user.\n *\n * @since 0.1.0\n */\n setUserJwt(options: SetUserJwtOptions): Promise<void>;\n /**\n * Update the attributes of the current user.\n *\n * @since 0.1.0\n */\n updateUser(options: UpdateUserOptions): Promise<void>;\n /**\n * Called when the Intercom Messenger is hidden.\n *\n * Only available on iOS and Web.\n *\n * @since 0.1.0\n */\n addListener(\n eventName: 'messengerHidden',\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Called when the Intercom Messenger is shown.\n *\n * Only available on iOS and Web.\n *\n * @since 0.1.0\n */\n addListener(\n eventName: 'messengerShown',\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Called when the number of unread conversations changes.\n *\n * @since 0.1.0\n */\n addListener(\n eventName: 'unreadConversationCountChange',\n listenerFunc: (event: UnreadConversationCountChangeEvent) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove all listeners for this plugin.\n *\n * @since 0.1.0\n */\n removeAllListeners(): Promise<void>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface GetUnreadConversationCountResult {\n /**\n * The number of unread conversations.\n *\n * @since 0.1.0\n */\n count: number;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface HandlePushNotificationOptions {\n /**\n * The data of the push notification.\n *\n * @since 0.1.0\n */\n data: Record<string, unknown>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface InitializeOptions {\n /**\n * The Android API key of your Intercom app.\n *\n * Required to use the plugin on Android.\n *\n * @since 0.1.0\n */\n androidApiKey?: string;\n /**\n * The app ID of your Intercom app.\n *\n * @since 0.1.0\n */\n appId: string;\n /**\n * The iOS API key of your Intercom app.\n *\n * Required to use the plugin on iOS.\n *\n * @since 0.1.0\n */\n iosApiKey?: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface IsIntercomPushNotificationOptions {\n /**\n * The data of the push notification.\n *\n * @since 0.1.0\n */\n data: Record<string, unknown>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface IsIntercomPushNotificationResult {\n /**\n * Whether the push notification belongs to Intercom.\n *\n * @since 0.1.0\n */\n intercom: boolean;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface LogEventOptions {\n /**\n * The metadata of the event.\n *\n * @since 0.1.0\n */\n data?: Record<string, string | number | boolean>;\n /**\n * The name of the event.\n *\n * @since 0.1.0\n */\n name: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface LoginUserOptions {\n /**\n * The email address of the user.\n *\n * @since 0.1.0\n */\n email?: string;\n /**\n * The unique identifier of the user.\n *\n * @since 0.1.0\n */\n userId?: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface PresentContentOptions {\n /**\n * The identifier of the content to present.\n *\n * Required for the `article`, `carousel`, `survey`, and `conversation`\n * content types.\n *\n * @since 0.1.0\n */\n id?: string;\n /**\n * The identifiers of the content to present.\n *\n * Required for the `help-center-collections` content type.\n *\n * @since 0.1.0\n */\n ids?: string[];\n /**\n * The type of content to present.\n *\n * @since 0.1.0\n */\n type: IntercomContentType;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface PresentMessageComposerOptions {\n /**\n * The message to pre-fill the composer with.\n *\n * @since 0.1.0\n */\n initialMessage?: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface PresentOptions {\n /**\n * The space to present.\n *\n * @default 'home'\n * @since 0.1.0\n */\n space?: IntercomSpace;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface SendPushTokenToIntercomOptions {\n /**\n * The push notification token.\n *\n * On Android, this is the Firebase Cloud Messaging (FCM) token. On iOS,\n * this is the hexadecimal APNs device token.\n *\n * @since 0.1.0\n */\n token: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface SetBottomPaddingOptions {\n /**\n * The bottom padding to set.\n *\n * @since 0.1.0\n */\n padding: number;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface SetInAppMessagesVisibleOptions {\n /**\n * Whether in-app messages should be visible.\n *\n * @since 0.1.0\n */\n visible: boolean;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface SetLauncherVisibleOptions {\n /**\n * Whether the launcher should be visible.\n *\n * @since 0.1.0\n */\n visible: boolean;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface SetUserHashOptions {\n /**\n * The user hash (HMAC) for identity verification.\n *\n * The hash must be generated on your backend using your Intercom secret\n * key. Never expose the secret key in your app.\n *\n * @since 0.1.0\n */\n userHash: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface SetUserJwtOptions {\n /**\n * The JSON Web Token (JWT) for identity verification.\n *\n * The token must be generated on your backend using your Intercom secret\n * key. Never expose the secret key in your app.\n *\n * @since 0.1.0\n */\n jwt: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface UnreadConversationCountChangeEvent {\n /**\n * The number of unread conversations.\n *\n * @since 0.1.0\n */\n count: number;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface UpdateUserCompany {\n /**\n * The date the company was created as a Unix timestamp in seconds.\n *\n * @since 0.1.0\n * @example 1704067200\n */\n createdAt?: number;\n /**\n * The custom attributes of the company.\n *\n * @since 0.1.0\n */\n customAttributes?: Record<string, string | number | boolean>;\n /**\n * The unique identifier of the company.\n *\n * @since 0.1.0\n */\n id: string;\n /**\n * The monthly spend of the company.\n *\n * @since 0.1.0\n */\n monthlySpend?: number;\n /**\n * The name of the company.\n *\n * @since 0.1.0\n */\n name?: string;\n /**\n * The plan of the company.\n *\n * @since 0.1.0\n */\n plan?: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface UpdateUserOptions {\n /**\n * The companies the user belongs to.\n *\n * @since 0.1.0\n */\n companies?: UpdateUserCompany[];\n /**\n * The custom attributes of the user.\n *\n * @since 0.1.0\n */\n customAttributes?: Record<string, string | number | boolean>;\n /**\n * The email address of the user.\n *\n * @since 0.1.0\n */\n email?: string;\n /**\n * The preferred language of the user as an ISO 639-1 code.\n *\n * @since 0.1.0\n * @example 'en'\n */\n languageOverride?: string;\n /**\n * The name of the user.\n *\n * @since 0.1.0\n */\n name?: string;\n /**\n * The phone number of the user.\n *\n * @since 0.1.0\n */\n phone?: string;\n /**\n * The date the user signed up as a Unix timestamp in seconds.\n *\n * @since 0.1.0\n * @example 1704067200\n */\n signedUpAt?: number;\n /**\n * Whether the user is unsubscribed from emails.\n *\n * @since 0.1.0\n */\n unsubscribedFromEmails?: boolean;\n /**\n * The unique identifier of the user.\n *\n * @since 0.1.0\n */\n userId?: string;\n}\n\n/**\n * A type of Intercom content that can be presented.\n *\n * @since 0.1.0\n */\nexport type IntercomContentType =\n | 'article'\n | 'carousel'\n | 'conversation'\n | 'help-center-collections'\n | 'survey';\n\n/**\n * A space of the Intercom Messenger.\n *\n * @since 0.1.0\n */\nexport type IntercomSpace = 'home' | 'messages' | 'help-center' | 'tickets';\n\n/**\n * @since 0.1.0\n */\nexport enum ErrorCode {\n /**\n * The login of the user failed.\n *\n * @since 0.1.0\n */\n LoginFailed = 'LOGIN_FAILED',\n /**\n * The plugin has not been initialized yet.\n *\n * Call `initialize(...)` before calling any other method.\n *\n * @since 0.1.0\n */\n NotInitialized = 'NOT_INITIALIZED',\n /**\n * The update of the user failed.\n *\n * @since 0.1.0\n */\n UpdateFailed = 'UPDATE_FAILED',\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { IntercomPlugin } from './definitions';
2
+ declare const Intercom: IntercomPlugin;
3
+ export * from './definitions';
4
+ export { Intercom };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const Intercom = registerPlugin('Intercom', {
3
+ web: () => import('./web').then(m => new m.IntercomWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { Intercom };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,QAAQ,GAAG,cAAc,CAAiB,UAAU,EAAE;IAC1D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;CAC1D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { IntercomPlugin } from './definitions';\n\nconst Intercom = registerPlugin<IntercomPlugin>('Intercom', {\n web: () => import('./web').then(m => new m.IntercomWeb()),\n});\n\nexport * from './definitions';\nexport { Intercom };\n"]}
@@ -0,0 +1,34 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { GetUnreadConversationCountResult, InitializeOptions, IntercomPlugin, LogEventOptions, LoginUserOptions, PresentContentOptions, PresentMessageComposerOptions, PresentOptions, SetInAppMessagesVisibleOptions, SetLauncherVisibleOptions, SetUserHashOptions, SetUserJwtOptions, UpdateUserOptions } from './definitions';
3
+ export declare class IntercomWeb extends WebPlugin implements IntercomPlugin {
4
+ private static readonly errorNotInitialized;
5
+ private static readonly errorNoWebEquivalent;
6
+ private appId?;
7
+ private initialized;
8
+ private unreadConversationCount;
9
+ private userHash?;
10
+ private userJwt?;
11
+ getUnreadConversationCount(): Promise<GetUnreadConversationCountResult>;
12
+ handlePushNotification(): Promise<void>;
13
+ hide(): Promise<void>;
14
+ initialize(options: InitializeOptions): Promise<void>;
15
+ isIntercomPushNotification(): Promise<never>;
16
+ logEvent(options: LogEventOptions): Promise<void>;
17
+ loginUnidentifiedUser(): Promise<void>;
18
+ loginUser(options: LoginUserOptions): Promise<void>;
19
+ logout(): Promise<void>;
20
+ present(options?: PresentOptions): Promise<void>;
21
+ presentContent(options: PresentContentOptions): Promise<void>;
22
+ presentMessageComposer(options?: PresentMessageComposerOptions): Promise<void>;
23
+ sendPushTokenToIntercom(): Promise<void>;
24
+ setBottomPadding(): Promise<void>;
25
+ setInAppMessagesVisible(options: SetInAppMessagesVisibleOptions): Promise<void>;
26
+ setLauncherVisible(options: SetLauncherVisibleOptions): Promise<void>;
27
+ setUserHash(options: SetUserHashOptions): Promise<void>;
28
+ setUserJwt(options: SetUserJwtOptions): Promise<void>;
29
+ updateUser(options: UpdateUserOptions): Promise<void>;
30
+ private boot;
31
+ private static mapSpace;
32
+ private registerEventListeners;
33
+ private throwIfNotInitialized;
34
+ }