forked from CleverTap/clevertap-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
792 lines (688 loc) · 25.1 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
/*******************
* Listners & Deeplinks
******************/
/**
* Add a CleverTap event listener
* supported events are CleverTap.CleverTapProfileDidInitialize, CleverTap.CleverTapProfileSync and CleverTap.CleverTapInAppNotificationDismissed
* @param {string} eventName - the CleverTap event name
* @param {function(event)} your event handler
*/
export function addListener(
eventName: string,
handler: Function
): void;
/**
* Removes all of the registered listeners for given eventName.
*
* @param {string} eventName - name of the event whose registered listeners to remove
*/
export function removeListener(eventName: string): void;
/**
* @deprecated - Since version 5.0.0. Use removeListener(eventName) instead
* Remove all event listeners
*/
export function removeListeners(): void;
/**
* If an application is launched from a push notification click, returns the CleverTap deep link included in the push notification
* @param {function(err, res)} callback that return the url as string in res or a string error in err
*/
export function getInitialUrl(callback: Callback): void;
/**
* Call this method to set Locale. If Language is english and country is US the locale format which you can set is en_US
* @param locale {string}
*/
export function setLocale(locale: string): void;
/*******************
* Personalization
******************/
/**
* Personalization
* Enables the Personalization API
*/
export function enablePersonalization(): void;
/**
* Enables tracking opt out for the currently active user.
* @param optOut {boolean}
*/
export function setOptOut(optOut: boolean): void;
/**
* Enables the reporting of device network related information, including IP address. This reporting is disabled by default.
* @param enable {boolean}
*/
export function enableDeviceNetworkInfoReporting(enable: boolean): void;
/*******************
* Push
******************/
/**
* Registers for push notifications
*/
export function registerForPush(): void;
/**
* Manually set the push token on the CleverTap user profile
* @param {string} token - the device token
* @param {string} type - for Android only, specifying the type of push service token. Values can be CleverTap.FCM for Firebase or CleverTap.XPS for Xiaomi or CleverTap.BPS for Baidu or CleverTap.HPS for Huawei,
* @param {string} region - for xps only ,to specify the region
*/
export function setPushToken(token: string, type: string,region?:string): void;
/**
* Create Notification Channel for Android O+
* @param channelID {string}
* @param channelName {string}
* @param channelDescription {string}
* @param importance {number}
* @param showBadge {boolean}
*/
export function createNotificationChannel(
channelID: string,
channelName: string,
channelDescription: string,
importance: number,
showBadge: boolean
): void;
/**
* Create Notification Channel for Android O+
* @param channelID {string}
* @param channelName {string}
* @param channelDescription {string}
* @param importance {number}
* @param showBadge {boolean}
* @param sound {string}
*/
export function createNotificationChannelWithSound(
channelID: string,
channelName: string,
channelDescription: string,
importance: number,
showBadge: boolean,
sound: string
): void;
/**
* Create Notification Channel with Group ID for Android O+
* @param channelID {string}
* @param channelName {string}
* @param channelDescription {string}
* @param importance {number}
* @param groupId {string}
* @param showBadge {boolean}
* @param sound {string}
*/
export function createNotificationChannelWithGroupId(
channelID: string,
channelName: string,
channelDescription: string,
importance: number,
groupId: string,
showBadge: boolean
): void;
/**
* Create Notification Channel with Group ID for Android O+
* @param channelID {string}
* @param channelName {string}
* @param channelDescription {string}
* @param importance {number}
* @param groupId {string}
* @param showBadge {boolean}
*/
export function createNotificationChannelWithGroupIdAndSound(
channelID: string,
channelName: string,
channelDescription: string,
importance: number,
groupId: string,
showBadge: boolean,
sound: string
): void;
/**
* Create Notification Channel Group for Android O+
* @param groupID {string}
* @param groupName {string}
*/
export function createNotificationChannelGroup(
groupID: string,
groupName: string
): void;
/**
* Delete Notification Channel for Android O+
* @param channelID {string}
*/
export function deleteNotificationChannel(channelID: string): void;
/**
* Delete Notification Group for Android O+
* @param groupID {string}
*/
export function deleteNotificationChannelGroup(groupID: string): void;
/**
* Create Notification for Custom Handling Push Notifications
* @param extras {any}
*/
export function createNotification(extras: any): void;
/**
* Call this method to prompt the hard permission dialog directly, if the push primer is not required.
* @param showFallbackSettings : {boolean} - Pass true to show an alert dialog which routes to app's notification settings page.
*/
export function promptForPushPermission(showFallbackSettings: boolean): void;
/**
* Call this method to prompt the push primer flow.
* @param localInAppConfig : {any} object
*/
export function promptPushPrimer(localInAppConfig: any): void;
/**
* Returns true/false based on whether push permission is granted or denied.
*
* @param {function(err, res)} non-null callback to retrieve the result
*/
export function isPushPermissionGranted(callback: CallbackString): void;
/*******************
* Events
******************/
/**
* Record Screen View
* @param screenName {string}
*/
export function recordScreenView(screenName: string): void;
/**
* Record Event with Name and Event properties
* @param eventName {string}
* @param eventProps {any}
*/
export function recordEvent(
eventName: string,
eventProps: any
): void;
/**
* Record Charged Event with Details and Items
* @param details {any} object with transaction details
* @param items {any} array of items purchased
*/
export function recordChargedEvent(
details: any,
items: any
): void;
/**
* Get Event First Time
* @param eventName {string}
* callback returns epoch seconds or -1
*/
export function eventGetFirstTime(eventName: string, callback: Callback): void;
/**
* Get Event Last Time
* @param eventName {string}
* callback returns epoch seconds or -1
*/
export function eventGetLastTime(eventName: string, callback: Callback): void;
/**
* Get Event Number of Occurrences
* @param eventName {string}
* calls back with int or -1
*/
export function eventGetOccurrences(eventName: string, callback: Callback): void;
/**
* Get Event Details
* @param eventName {string}
* calls back with object {"eventName": <string>, "firstTime":<epoch seconds>, "lastTime": <epoch seconds>, "count": <int>} or empty object
*/
export function eventGetDetail(eventName: string, callback: Callback): void;
/**
* Get Event History
* calls back with object {"eventName1":<event1 details object>, "eventName2":<event2 details object>}
*/
export function getEventHistory(callback: Callback): void;
/**
* Set location
* @param lat {number}
* @param lon {number}
*/
export function setLocation(lat: number, lon: number): void;
/**
* Creates a separate and distinct user profile identified by one or more of Identity, Email, FBID or GPID values,
* and populated with the key-values included in the profile dictionary.
* If your app is used by multiple users, you can use this method to assign them each a unique profile to track them separately.
* If instead you wish to assign multiple Identity, Email, FBID and/or GPID values to the same user profile,
* use profileSet rather than this method.
* If none of Identity, Email, FBID or GPID is included in the profile dictionary,
* all properties values will be associated with the current user profile.
* When initially installed on this device, your app is assigned an "anonymous" profile.
* The first time you identify a user on this device (whether via onUserLogin or profileSet),
* the "anonymous" history on the device will be associated with the newly identified user.
* Then, use this method to switch between subsequent separate identified users.
* Please note that switching from one identified user to another is a costly operation
* in that the current session for the previous user is automatically closed
* and data relating to the old user removed, and a new session is started
* for the new user and data for that user refreshed via a network call to CleverTap.
* In addition, any global frequency caps are reset as part of the switch.
* @param profile {any} object
*/
export function onUserLogin(profile: any): void;
/**
* Set profile attributes
* @param profile {any} object
*/
export function profileSet(profile: any): void;
/**
* Get User Profile Property
* @param propertyName {string}
* calls back with value of propertyName or false
*/
export function profileGetProperty(propertyName: string, callback: Callback): void;
/**
* @deprecated
* Since version 0.6.0. Use `getCleverTapID(callback)` instead.
*
* Get a unique CleverTap identifier suitable for use with install attribution providers.
* @param {function(err, res)} callback that returns a string res
*/
export function profileGetCleverTapAttributionIdentifier(callback: CallbackString): void;
/**
* @deprecated
* Since version 0.6.0. Use `getCleverTapID(callback)` instead.
*
* Get User Profile CleverTapID
* @param {function(err, res)} callback that returns a string res
*/
export function profileGetCleverTapID(callback: CallbackString): void;
/**
* Returns a unique identifier through callback by which CleverTap identifies this user
*
* @param {function(err, res)} non-null callback to retrieve identifier
*/
export function getCleverTapID(callback: CallbackString): void;
/**
* Remove the property specified by key from the user profile. Alternatively this method
* can also be used to remove PII data (for eg. Email,Name,Phone), locally from database and shared prefs
* @param key {string}
*/
export function profileRemoveValueForKey(key: string): void;
/**
* Method for setting a multi-value user profile property
* @param key {string}
* @param values {any} array of strings
*/
export function profileSetMultiValuesForKey(values: any, key: string): void;
/**
* Method for adding a value to a multi-value user profile property
* @param key {string}
* @param value {string}
*/
export function profileAddMultiValueForKey(value: string, key: string): void;
/**
* Method for adding values to a multi-value user profile property
* @param key {string}
* @param values {any} array of strings
*/
export function profileAddMultiValuesForKey(values: any, key: string): void;
/**
* Method for removing a value from a multi-value user profile property
* @param key {string}
* @param value {string}
*/
export function profileRemoveMultiValueForKey(value: string, key: string): void;
/**
* Method for removing a value from a multi-value user profile property
* @param key {string}
* @param values {any} array of strings
*/
export function profileRemoveMultiValuesForKey(values: any, key: string): void;
/*******************************
* Increment/Decrement Operators
*******************************/
/**
* This method is used to increment the given value
*
* @param value {Number} can be int,double or float only (NaN,Infinity etc not supported)
* @param key {string} profile property
*/
export function profileIncrementValueForKey(value:number, key:string): void;
/**
* This method is used to decrement the given value
*
* @param value {Number} can be int,double or float only (NaN,Infinity etc not supported)
* @param key {string} profile property
*/
export function profileDecrementValueForKey(value:number, key:string): void;
/*******************
* Session
******************/
/**
* Get Session Elapsed Time
* calls back with seconds
*/
export function sessionGetTimeElapsed(callback: Callback): void;
/**
* Get Session Total Visits
* calls back with int or -1
*/
export function sessionGetTotalVisits(callback: Callback): void;
/**
* Get Session Screen Count
* calls back with with int
*/
export function sessionGetScreenCount(callback: Callback): void;
/**
* Get Session Previous Visit Time
* calls back with epoch seconds or -1
*/
export function sessionGetPreviousVisitTime(callback: Callback): void;
/**
* Get Sesssion Referrer UTM details
* object {"source": <string>, "medium": <string>, "campaign": <string>} or empty object
*/
export function sessionGetUTMDetails(callback: Callback): void;
/**
* Call this to manually track the utm details for an incoming install referrer
* @param source {string}
* @param medium {string}
* @param campaign {string}
*/
export function pushInstallReferrer(
source: string,
medium: string,
campaign: string
): void;
/****************************
* Notification Inbox methods
****************************/
/**
* Call this method to initialize the App Inbox
*/
export function initializeInbox(): void;
/**
* Call this method to get the count of unread Inbox messages
*/
export function getInboxMessageUnreadCount(callback: Callback): void;
/**
* Call this method to get the count of total Inbox messages
*/
export function getInboxMessageCount(callback: Callback): void;
/**
* Call this method to open the App Inbox
* @param styleConfig : any or empty object
*/
export function showInbox(styleConfig: any): void;
/**
* Call this method to dismiss the App Inbox
*/
export function dismissInbox(): void;
/**
* Call this method to get all inbox messages
*/
export function getAllInboxMessages(callback: Callback): void;
/**
* Call this method to get all unread inbox messages
*/
export function getUnreadInboxMessages(callback: Callback): void;
/**
* Call this method to get inbox message that belongs to the given message id
*/
export function getInboxMessageForId(messageId: string, callback: Callback): void;
/**
* Call this method to delete inbox message that belongs to the given message id
*/
export function deleteInboxMessageForId(messageId: string): void;
/**
* Call this method to delete multiple inbox messages that belongs to the given message ids
*/
export function deleteInboxMessagesForIDs(messageIds: any): void;
/**
* Call this method to mark inbox message as read
*/
export function markReadInboxMessageForId(messageId: string): void;
/**
* Call this method to mark multiple inbox messages as read
*/
export function markReadInboxMessagesForIDs(messageIds: any): void;
/**
* Call this method to push the Notification Clicked event for App Inbox to CleverTap
*/
export function pushInboxNotificationClickedEventForId(messageId: string): void;
/**
* Call this method to push the Notification Viewed event for App Inbox to CleverTap
*/
export function pushInboxNotificationViewedEventForId(messageId: string): void;
/****************************
* Native Display Methods
****************************/
/**
* Call this method to get all display units
*/
export function getAllDisplayUnits(callback: Callback): void;
/**
* Call this method to get display unit that belongs to the given unit id
*/
export function getDisplayUnitForId(unitID: string, callback: Callback): void;
/**
* Call this method to raise display unit viewed event
*/
export function pushDisplayUnitViewedEventForID(unitID: string): void;
/**
* Call this method to raise display unit clicked event
*/
export function pushDisplayUnitClickedEventForID(unitID: string): void;
/*******************
* Product Configs
******************/
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Sets default product config params using the given object.
* @param productConfigMap {any} key-value product config properties. keys are strings and values can be string, double, integer, boolean or json in string format.
*/
export function setDefaultsMap(productConfigMap: any): void;
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Starts fetching product configs, adhering to the default minimum fetch interval.
*/
export function fetch(): void;
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Starts fetching product configs, adhering to the default minimum fetch interval.
* @param intervalInSecs {number} minimum fetch interval in seconds.
*/
export function fetchWithMinimumIntervalInSeconds(intervalInSecs: number): void;
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Activates the most recently fetched product configs, so that the fetched key value pairs take effect.
*/
export function activate(): void;
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Asynchronously fetches and then activates the fetched product configs.
*/
export function fetchAndActivate(): void;
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Sets the minimum interval in seconds between successive fetch calls.
* @param intervalInSecs {number} interval in seconds between successive fetch calls.
*/
export function setMinimumFetchIntervalInSeconds(intervalInSecs: number): void;
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Deletes all activated, fetched and defaults configs as well as all Product Config settings.
*/
export function resetProductConfig(): void;
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Returns the product config parameter value for the given key as a String.
* @param key {string} - the name of the key
* @param callback {Callback} - callback that returns a value of type string if present else blank
*/
export function getProductConfigString(
key: string,
callback: Callback): void;
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Returns the product config parameter value for the given key as a boolean.
* @param key {string} - the name of the key
* @param callback {Callback} - callback that returns a value of type boolean if present else false
*/
export function getProductConfigBoolean(
key: string,
callback: Callback): void;
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Returns the product config parameter value for the given key as a number.
* @param key {string} - the name of the key
* @param callback {Callback} - callback that returns a value of type number if present else 0
*/
export function getNumber(
key: string,
callback: Callback): void;
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Returns the last fetched timestamp in millis.
* @param callback {Callback} - callback that returns value of timestamp in millis as a string.
*/
export function getLastFetchTimeStampInMillis(callback: Callback): void;
/*******************
* Feature Flags
******************/
/**
* @deprecated
* Since version 1.1.0 and will be removed in the future versions of this SDK.
*
* Getter to return the feature flag configured at the dashboard
* @param key {string} - the name of the key
* @param defaultValue {boolean} - default value of the key, in case we don't find any feature flag with the key.
* @param callback {Callback} - callback that returns a feature flag value of type boolean if present else provided default value
*/
export function getFeatureFlag(
key: string,
defaultValue: boolean,
callback: Callback): void;
/*******************
* InApp Controls
******************/
/**
* Suspends display of InApp Notifications.
* The InApp Notifications are queued once this method is called
* and will be displayed once resumeInAppNotifications() is called.
*/
export function suspendInAppNotifications(): void;
/**
* Suspends the display of InApp Notifications and discards any new InApp Notifications to be shown
* after this method is called.
* The InApp Notifications will be displayed only once resumeInAppNotifications() is called.
*/
export function discardInAppNotifications(): void;
/**
* Resumes display of InApp Notifications.
*
* If suspendInAppNotifications() was called previously, calling this method will instantly show
* all queued InApp Notifications and also resume InApp Notifications on events raised after this
* method is called.
*
* If discardInAppNotifications() was called previously, calling this method will only resume
* InApp Notifications on events raised after this method is called.
*/
export function resumeInAppNotifications(): void;
/*******************
* Instances
******************/
/**
* Change the native instance of CleverTapAPI by using the instance for
* specific account. Used by Leanplum RN SDK.
*
* @param accountId {string} - The ID of the account to use when switching instance.
*/
export function setInstanceWithAccountId(accountId: string): void;
/*******************
* Product Experiences: Vars
******************/
/**
* Uploads variables to the server. Requires Development/Debug build/configuration.
*/
export function syncVariables(): void;
/**
* Uploads variables to the server.
*
* @param isProduction Provide `true` if variables must be sync in Productuon build/configuration.
*/
export function syncVariablesinProd(isProduction: boolean): void;
/**
* Forces variables to update from the server.
*
* @param {function(err, res)} a callback with a boolean flag whether the update was successful.
*/
export function fetchVariables(callback: Callback): void;
/**
* Create variables.
*
* @param {object} variables The JSON Object specifying the varibles to be created.
*/
export function defineVariables(variables: object): void;
/**
* Get all variables via a JSON object.
*
*/
export function getVariables(callback: Callback): void;
/**
* Get a variable or a group for the specified name.
*
* @param {string} name - name.
*/
export function getVariable(name: string, callback: Callback): void;
/**
* Adds a callback to be invoked when variables are initialised with server values. Will be called each time new values are fetched.
*
* @param {function} handler The callback to add
*/
export function onVariablesChanged(handler: Function): void;
/**
* Called when the value of the variable changes.
*
* @param {name} string the name of the variable
* @param {function} handler The callback to add
*/
export function onValueChanged(name: string, handler: Function): void;
/*******************
* Developer Options
******************/
/**
* 0 is off, 1 is info, 2 is debug, default is 1
* @param level {number}
*/
export function setDebugLevel(level: number): void;
type Callback = (err: object, res: object) => void;
type CallbackString = (err: object, res: string) => void;
export const FCM: string;
export const XPS: string;
export const BPS: string;
export const HPS: string;
export const CleverTapProfileDidInitialize: string;
export const CleverTapProfileSync: string;
export const CleverTapInAppNotificationDismissed: string;
export const CleverTapInAppNotificationShowed: string;
export const CleverTapInboxDidInitialize: string;
export const CleverTapInboxMessagesDidUpdate: string;
export const CleverTapInboxMessageButtonTapped: string;
export const CleverTapInboxMessageTapped: string;
export const CleverTapDisplayUnitsLoaded: string;
export const CleverTapInAppNotificationButtonTapped: string;
export const CleverTapFeatureFlagsDidUpdate: string;
export const CleverTapProductConfigDidInitialize: string;
export const CleverTapProductConfigDidFetch: string;
export const CleverTapProductConfigDidActivate: string;
export const CleverTapPushNotificationClicked: string;
export const CleverTapPushPermissionResponseReceived: string;
export const CleverTapOnVariablesChanged: string;
export const CleverTapOnValueChanged: string;