-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathindex.js
1230 lines (1060 loc) · 39.7 KB
/
index.js
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
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright © 2024, Oracle and/or its affiliates. All rights reserved.
*
* Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl.
*/
import { NativeModules, NativeEventEmitter, DeviceEventEmitter, Platform } from 'react-native';
const RCTPushIOManager = NativeModules.PushIOManager;
const RCTPushIOEventEmitter = Platform.select({
ios: new NativeEventEmitter(NativeModules.PushIOEventEmitter),
android: DeviceEventEmitter
});
export default class PushIOManager {
/**
*@callback callback
*@param {failure} error object
*@param {success} info object
*/
/**
* @typedef {object} Preference
* @property {string} key - Unique Identifier for this preference.
* @property {string} label - Human-Readable description of this preference.
* @property {string} type - Data type of this preference. Possible values: 'STRING', 'NUMBER', 'BOOLEAN'.
* @property {string} value - Preference value.
*/
/**
* @typedef {object} MessageCenterMessage
* @property {string} messageID
* @property {string} subject
* @property {string} message
* @property {string} iconURL
* @property {string} messageCenterName
* @property {string} deeplinkURL
* @property {string} richMessageHTML
* @property {string} richMessageURL
* @property {string} sentTimestamp
* @property {string} expiryTimestamp
*/
/**
* @typedef {object} InteractiveNotificationCategory
* @property {string} orcl_category
* @property {InteractiveNotificationButton[]} orcl_btns
*/
/**
* @typedef {object} InteractiveNotificationButton
* @property {string} id
* @property {string} action
* @property {string} label
*/
/**
* @typedef {object} RemoteMessage
* @property {string} to
* @property {string=} collapseKey
* @property {string=} messageId
* @property {string=} messageType
* @property {string=} ttl
* @property {object} data
*/
/**
* @typedef {object} GeoRegion
* @property {string} geofenceId
* @property {string} geofenceName
* @property {string} zoneName
* @property {string} zoneId
* @property {string} source
* @property {number} deviceBearing
* @property {number} deviceSpeed
* @property {number} dwellTime
* @property {object} extra
*/
/**
* @typedef {object} BeaconRegion
* @property {string} beaconId
* @property {string} beaconName
* @property {string} beaconTag
* @property {string} beaconProximity
* @property {string} iBeaconUUID
* @property {number} iBeaconMajor
* @property {number} iBeaconMinor
* @property {string} eddyStoneId1
* @property {string} eddyStoneId2
* @property {string} zoneName
* @property {string} zoneId
* @property {string} source
* @property {number} dwellTime
* @property {object} extra
*/
/**
* @typedef {object} ConversionEvent
* @property {string} orderId
* @property {number} orderTotal
* @property {number} orderQuantity
* @property {number} conversionType
* @property {object} customProperties
*/
/**
*
* loggingLevel; to be used with [setLogLevel()]{@link setLogLevel}
* @typedef {Enumerator}loggingLevel
* @param {number} NONE:0
* @param {number} ERROR :1
* @param {number} INFO: 2
* @param {number} WARN: 3
* @param {number} DEBUG: 4
* @param {number} VERBOSE: 5
* @readonly
* @enum {number}
* @memberof PushIOManager
*
*/
/**
* Sets the log level to print in console.
* @param {number} loggingLevel Numeric value to set type of logging
*/
static setLogLevel(loggingLevel) {
RCTPushIOManager.setLogLevel(loggingLevel);
}
/**
* Gets the Responsys SDK version.
* @param {callback} callback Success callback with the SDK version value.
*/
static getLibVersion(callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.getLibVersion(callback);
} else {
RCTPushIOManager.frameworkVersion(callback);
}
}
/**
* Sets Enable/Disable logging. By default logging is enabled with default Info {@link loggingLevel}.
* <br/>Developer can change the log level by calling {@link setLogLevel}.
* @param {boolean} isEnabled true, enable console log printing.
* <br/> false, disable console log printing.
*
*/
static setLoggingEnabled(isEnabled) {
RCTPushIOManager.setLoggingEnabled(isEnabled);
}
/**
* Registers this app installation with Responsys.
*
* @param {boolean} enablePushNotification Whether to enable push notifications. Passing `true` will show the default system push notification permission dialog prompt.
* (Not available on iOS platform.)
* @param {boolean} useLocation Whether to send location data along with the registration request. Passing `true` will show the default system location permission dialog prompt.
* (User location is not available on iOS platform.)
* @param {callback} callback callback with boolean value TRUE if register event created and stored successfully, FALSE otherwise.
* @see {@tutorial Config}
*/
static registerAppForPush(enablePushNotification, useLocation, callback){
if(Platform.OS === 'android'){
RCTPushIOManager.registerAppForPush(enablePushNotification,useLocation,callback);
}else{
RCTPushIOManager.registerApp(useLocation,callback);
}
}
/**
* Registers this app installation with Responsys
*
* @param {boolean} useLocation Whether to send location data along with the registration request. Passing `true` will show the default system location permission dialog prompt.
* @param {callback} callback callback with boolean value TRUE if register event created and stored successfully, FALSE otherwise.
* @see {@tutorial Config}
*/
static registerApp(useLocation,callback){
if(Platform.OS === 'android'){
console.log("This API is no longer supported. Use PushIOManager.registerAppForPush() for Android.");
}else{
RCTPushIOManager.registerApp(useLocation,callback);
}
}
/**
* Unregister this app installation with Responsys. This will prevent the app from receiving push notifications.
* @see {@tutorial Config}
* @param {callback} callback callback with boolean value TRUE if unregister event created and stored successfully,
* <br/>FALSE otherwise.
*
*/
static unregisterApp(callback) {
RCTPushIOManager.unregisterApp(callback);
}
/**
* Configures the SDK using the provided config file name.
* <br/>For Android, the file should be placed in the android <i>src/main/assets</i> directory
* @see {@tutorial Config}
* @param {string} fileName Name of the json config file.
* @param {callback} callback callback with the result of configuration.
*
*
*/
static configure(fileName, callback) {
RCTPushIOManager.configure(fileName, callback);
}
/**
* Overwrites the Responsys API key provided in the pushio_config.json - this method should be called immediately after creating a new PushIOManager.
*
* @param {string} apiKey The new API key.
*/
static overwriteApiKey(apiKey) {
RCTPushIOManager.overwriteApiKey(apiKey);
}
/**
* Overwrites the Responsys API key provided in the pushio_config.json -
* this method should be called immediately after creating a new PushIOManager.
*
* @param {string} accountToken The new Account token
*/
static overwriteAccountToken(accountToken) {
RCTPushIOManager.overwriteAccountToken(accountToken);
}
/**
* Records pre-defined and custom events.
* <br/>You can set extra properties specific to this event via the properties parameter.
*
* @param {string} eventName name of the event to be tracked
* @param {object} properties event properties to attach with the given event name.
* @param {function} callback callback.
*/
static trackEvent(eventName, properties) {
RCTPushIOManager.trackEvent(eventName, properties);
}
/**
* Sets the External Device Tracking ID. Useful if you have another ID for this device.
* @param {string} externalDeviceTrackingID External Device Tracking ID.
*/
static setExternalDeviceTrackingID(externalDeviceTrackingID) {
RCTPushIOManager.setExternalDeviceTrackingID(externalDeviceTrackingID);
}
/**
* Gets the External Device Tracking ID.
* @param {callback} callback callback with External Device Tracking ID
*/
static getExternalDeviceTrackingID(callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.getExternalDeviceTrackingID(callback);
} else {
RCTPushIOManager.externalDeviceTrackingID(callback);
}
}
/**
* Associates this app installation with the provided userId in Responsys.
* <br/> UserId can be set to target individual users for push notifications, sent along with push registration.
* @param {string} userId User ID
*/
static registerUserId(userId) {
RCTPushIOManager.registerUserId(userId);
}
/**
* Gets the User ID set earlier using [registerUserId]{@link registerUserId}.
* @param {callback} callback callback with userId
*/
static getRegisteredUserId(callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.getRegisteredUserId(callback);
} else {
RCTPushIOManager.getUserId(callback);
}
}
/**
* Removes association between this app installation and the User ID that
* was set earlier using [registerUserId]{@link registerUserId}.
* <br/>Generally used when the user logs out.
*/
static unregisterUserId() {
RCTPushIOManager.unregisterUserId();
}
/**
* Sends push engagement information to Responsys.
* <br>Tracks the engagement for the provided engagement metric type with additional properties
*
* @param {engagementType} metric One of [engagementType]{@link engagementType}
* @param {object=} properties Custom data to be sent along with this request.
* @param {callback} callback callback.
*/
static trackEngagement(metric, properties, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.trackEngagement(metric, properties, callback);
} else {
var value = ((metric < 6) ? (metric - 1) : metric);
RCTPushIOManager.trackEngagement(value, properties, callback);
}
}
/**
* Sends the MessageCenter open engagement for the provided message id to Responsys. Call this whenever message is opened.
* <br/><br/>This should be called when the message-detail view is visible to the user
* @param {string} messageID engagement message id to be reported
*/
static trackMessageCenterOpenEngagement(messageId) {
RCTPushIOManager.trackMessageCenterOpenEngagement(messageId);
}
/**
* Sends Message Center message engagement to Responsys.
* <br/>This should be called when the message-list view is visible to the user.
* @param {string} messageID engagement message id to be reported
*/
static trackMessageCenterDisplayEngagement(messageId) {
RCTPushIOManager.trackMessageCenterDisplayEngagement(messageId);
}
/**
* Create a session when MessagaCenter/Inbox view will appear.
*/
static onMessageCenterViewDisplayed() {
if (Platform.OS === 'android') {
RCTPushIOManager.onMessageCenterViewDisplayed();
} else {
RCTPushIOManager.messageCenterViewWillAppear();
}
}
/**
* Sync all the MessageCenter display engagements to Responsys server
*/
static onMessageCenterViewFinished() {
if (Platform.OS === 'android') {
RCTPushIOManager.onMessageCenterViewFinished();
} else {
RCTPushIOManager.messageCenterViewWillDisappear();
}
}
/**
* Declares a preference that will be used later with [set...Preference()]{@link setStringPreference}
*
* @param {string} key Unique ID for this preference.
* @param {string} label Human-Readable description of this preference.
* @param {string} valueType Data type of this preference. Possible values: 'STRING', 'NUMBER', 'BOOLEAN'.
* @param {callback} callback Success callback.
*
* @see {@link setBoolPreference}
* @see {@link setNumberPreference}
* @see {@link setStringPreference}
*/
static declarePreference(key, label, valueType, callback) {
RCTPushIOManager.declarePreference(key, label, valueType, callback);
}
/**
* Saves the key/value along with the label provided earlier in [declarePreference]{@link declarePreference}
*
* @param {string} key Unique ID for this preference.
* @param {string} value Value of type String.
* @param {callback} callback callback with boolean value TRUE if string preference value assigned, FALSE otherwise
*/
static setStringPreference(key, value, callback) {
RCTPushIOManager.setStringPreference(key, value, callback);
}
/**
* Saves the key/value along with the label provided earlier in [declarePreference]{@link declarePreference}
*
* @param {string} key Unique ID for this preference.
* @param {number} value Value of type Number.
* @param {callback} callback Success callback.
*/
static setNumberPreference(key, value, callback) {
RCTPushIOManager.setNumberPreference(key, value, callback);
}
/**
* Saves the key/value along with the label provided earlier in [declarePreference]{@link declarePreference}
*
* @param {string} key Unique ID for this preference.
* @param {boolean} value Value of type Boolean.
* @param {callback} callback callback with preference if preference is found for the key, NULL otherwise.
*/
static setBooleanPreference(key, value, callback) {
RCTPushIOManager.setBooleanPreference(key, value, callback);
}
/**
* Gets all preferences set earlier using [set...Preference()]{@link setStringPreference}.
* @param {String} key Unique ID of preference.
* @param {callback} callback callback with preference if preference is found for the key, NULL otherwise.
*/
static getPreference(key, callback) {
RCTPushIOManager.getPreference(key, callback);
}
/**
* Gets all preferences set earlier using [set...Preference()]{@link setStringPreference}.
* @param {function} callback Success callback with {Preference[]} Array of [Preference]{@link Preference} in success callback.
*/
static getPreferences(callback) {
RCTPushIOManager.getPreferences(callback);
}
/**
* Removes preference data for the given key.
*
* @param {string} key Unique ID for this preference.
*/
static removePreference(key) {
RCTPushIOManager.removePreference(key);
}
/**
* Removes all preference data.
*/
static clearAllPreferences() {
RCTPushIOManager.clearAllPreferences();
}
/**
* Gets the API Key used by the device to register with Responsys.
* @param {function} callback callback with configured APIKey. nil if no api-key configured.
*/
static getAPIKey(callback) {
RCTPushIOManager.getAPIKey(callback);
}
/**
* Gets the Account Token used by the device to register with Responsys.
* @param {callback} callback callback with configured AccountToken. nil if no AccountToken configured
*/
static getAccountToken(callback) {
RCTPushIOManager.getAccountToken(callback);
}
/**
* Sets the advertising ID.
* @param {string} advertisingId External Device Tracking ID.
*/
static setAdvertisingID(advertisingId) {
if (Platform.OS === 'android') {
RCTPushIOManager.setAdvertisingID(advertisingId);
} else {
RCTPushIOManager.setAdvertisingIdentifier(advertisingId);
}
}
/**
* Gets the advertising ID.
* <br/> In iOS, its Advertising Identifier (IDFA) (@link setAdvertisingID}
* @param {callback} callback Success callback with advertising Identifier.
*/
static getAdvertisingID(callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.getAdvertisingID(callback);
} else {
RCTPushIOManager.advertisingIdentifier(callback);
}
}
/**
* Gets the Responsys Device ID.
* @param {callback} callback Success callback with device ID value.
*/
static getDeviceID(callback) {
RCTPushIOManager.getDeviceID(callback);
}
/**
* sets the Responsys web URL.
*
* @param {string} executeRsysWebURL url
*/
static setExecuteRsysWebUrl(executeRsysWebURL) {
RCTPushIOManager.setExecuteRsysWebURL(executeRsysWebURL);
}
/**
* Gets the Responsys web URL.
*
* @param {callback} callback Success callback with device ID value.
*/
static getExecuteRsysWebUrl(callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.getExecuteRsysWebUrl(callback);
} else {
RCTPushIOManager.executeRsysWebURL(callback);
}
}
/**
* Removes push engagement related data for a session.
* <br/>This will prevent further engagements from being reported until the app is opened again via a push notification.
*/
static resetEngagementContext() {
RCTPushIOManager.resetEngagementContext();
}
/**
* Gets the maximum age of engagement
* @param {callback} callback callback with number value of server returned max age value (when application invoked from email).
* <br/> Return -1 if no max age (from server) fetched.
*/
static getEngagementMaxAge(callback) {
RCTPushIOManager.getEngagementMaxAge(callback);
}
/**
* Gets the engagement date recorded when engagement information fetched from server and stored locally.
* @param {callback} callback callback with string value of engagement date,time in ISO 8601 format
*/
static getEngagementTimestamp(callback) {
RCTPushIOManager.getEngagementTimestamp(callback);
}
/**
* Enable the fetch messages for all message center names from the server
* @param {boolean} messageCenterEnabled boolean value to enable the messages fetch.
* <br/> True to enable ,False to disable.
*/
static setMessageCenterEnabled(messageCenterEnabled) {
RCTPushIOManager.setMessageCenterEnabled(messageCenterEnabled);
}
/**
* Gets the status of MessageCenter enabled
* @param {function} callback callback with boolean value.
*/
static isMessageCenterEnabled(callback) {
RCTPushIOManager.isMessageCenterEnabled(callback);
}
/**
* Fetch the list of Message Center messages for given MessageCenter name.
*
* @param {string} messageCenter Name of MessageCenter to fetch the list of messages
* @param {callback} callback Success callback with messageCenter and messages, Failure callback with messageCenter and errorReason
*/
static fetchMessagesForMessageCenter(messageCenter, callback) {
RCTPushIOManager.fetchMessagesForMessageCenter(messageCenter, callback);
}
/**
* Fetches rich content for the given message ID.
*
* @param {string} messageID
* @param {callback} callback Success callback with messageId and richContent, Failure callback with messageId and errorReason
*/
static fetchRichContentForMessage(messageId, callback) {
RCTPushIOManager.fetchRichContentForMessage(messageId, callback);
}
/**
* Sets the badge count on app icon for the no. of Message Center messages.
*
* @param {number} badgeCount
* @param {boolean} forceSetBadge Force a server-sync for the newly set badge count.
* @param {callback} callback callback.
*/
static setBadgeCount(badgeCount, forceSetBadge, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.setBadgeCount(badgeCount, forceSetBadge, callback);
} else {
RCTPushIOManager.setBadgeCount(badgeCount, callback);
}
}
/**
* Gets the current badge count for Message Center messages.
*
* @param {callback} callback callback as a number value.
*/
static getBadgeCount(callback) {
RCTPushIOManager.getBadgeCount(callback);
}
/**
* Resets the badge count for Message Center messages.<br/>This is equivalent to calling [setBadgeCount(0, true)]{@link PushIOManager#setsetBadgeCount}
*
* @param {boolean} forceSetBadge Force a server-sync for the newly set badge count.
* @param {callback} callback callback.
*/
static resetBadgeCount(forceSetBadge, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.resetBadgeCount(forceSetBadge, callback);
} else {
RCTPushIOManager.resetBadgeCount(callback);
}
}
/**
* Removes all Message Center messages from the SDK's cache.<br/><br/>This does not affect your local cache of the messages.
*/
static resetMessageCenter() {
if (Platform.OS === 'android') {
RCTPushIOManager.resetMessageCenter();
} else {
RCTPushIOManager.clearMessageCenterMessages();
}
}
/**
* Removes all In-App messages from the SDK's cache.
*
*/
static clearInAppMessages() {
RCTPushIOManager.clearInAppMessages();
}
/**
* Enable/Disable the in-app messages pre-fetch.
* <br/>If enabled, all the in-app messages are pre-fetch and stored in the SDK, and triggered from local storage.
* <br/>If disabled then in-app messages are not pre-fetched, so not available to be triggered for the event i.e.: $ExplicitAppOpen.
* @param {Boolean} isEnabled
*/
static setInAppFetchEnabled(isEnabled) {
if (Platform.OS === 'android') {
RCTPushIOManager.setInAppFetchEnabled(isEnabled);
} else {
RCTPushIOManager.setInAppMessageFetchEnabled(isEnabled);
}
}
/**
* Enable the crash logging of PushIO sdk.
* <br/>It will not make and capture any crashes of apps. By default it is enable. You can set `NO`
* <br/>if you do not want PushIO sdk to collect crashes.
* @param {Boolean} isEnabled boolean value to enable the crash logging.
*/
static setCrashLoggingEnabled(isEnabled) {
if (Platform.OS === 'android') {
RCTPushIOManager.setCrashLoggingEnabled(isEnabled);
} else {
console.log("API not supported");
}
}
/**
* Check if crash logging is enabled for PushIOManager SDK. We capture only crashes related to sdk.
* @param {callback} callback with boolean value
*/
static isCrashLoggingEnabled(callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.isCrashLoggingEnabled(callback);
} else {
console.log("API not supported");
}
}
/**
* Sets the device token
* <br/> available in Android only
* @param {string} deviceToken
*/
static setDeviceToken(deviceToken) {
if (Platform.OS === 'android') {
RCTPushIOManager.setDeviceToken(deviceToken);
} else {
console.log("API not supported. Please use `didRegisterForRemoteNotificationsWithDeviceToken`");
}
}
/**
* Checks if the push payload provided is sent by Responsys platform or not.
* @param {object} message
* @param {callback} callback
*/
static isResponsysPush(message, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.isResponsysPush(message, callback);
} else {
RCTPushIOManager.isResponsysPayload(message, callback);
}
}
/**
* Informs the SDK that the user has entered a geo-fence.
* @param {GeoRegion} region
* @param {callback} callback callback with regionID and regionType.
*/
static onGeoRegionEntered(region, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.onGeoRegionEntered(region, callback);
} else {
RCTPushIOManager.didEnterGeoRegion(region, callback);
}
}
/**
* Informs the SDK that the user has exited a geo-fence.
*
* @param {GeoRegion} region
* @param {callback} callback callback with regionID and regionType.
*/
static onGeoRegionExited(region, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.onGeoRegionExited(region, callback);
} else {
RCTPushIOManager.didExitGeoRegion(region, callback);
}
}
/**
* Informs the SDK that the user has entered a beacon region.
*
* @param {BeaconRegion} region
* @param {callback} callback callback with regionID and regionType.
*/
static onBeaconRegionEntered(region, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.onBeaconRegionEntered(region, callback);
} else {
RCTPushIOManager.didEnterBeaconRegion(region, callback);
}
}
/**
* Informs the SDK that the user has exited a beacon region.
*
* @param {BeaconRegion} region
* @param {callback} callback callback with regionID and regionType.
*/
static onBeaconRegionExited(region, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.onBeaconRegionExited(region, callback);
} else {
RCTPushIOManager.didExitBeaconRegion(region, callback);
}
}
/**
* Sends Message Center message engagement to Responsys.
* <br/>This should be called when the message-list view is visible to the user.
* @param {string} messageID
*/
static trackMessageCenterDisplayEngagement(messageID) {
RCTPushIOManager.trackMessageCenterDisplayEngagement(messageID);
}
/**
* Sends Message Center message engagement to Responsys.
* <br/>This should be called when the message-detail view is visible to the user.
* @param {string} messageID
*/
static trackMessageCenterOpenEngagement(messageID) {
RCTPushIOManager.trackMessageCenterOpenEngagement(messageID);
}
/**
* Create a session when Message Center/Inbox view will appear.
*/
static messageCenterViewDidMount() {
if (Platform.OS === 'android') {
RCTPushIOManager.onMessageCenterViewVisible();
} else {
RCTPushIOManager.messageCenterViewWillAppear();
}
}
/**
* Sync all the MessageCenter display engagements to responsys server.
*/
static messageCenterViewWillUnmount() {
if (Platform.OS === 'android') {
RCTPushIOManager.onMessageCenterViewFinish();
} else {
RCTPushIOManager.messageCenterViewWillDisappear();
}
}
// Android-Only APIs
/**
* Sets Enable/Disable the Message Center badging
* @param {Boolean} isBadgingEnabled
*/
static setMessageCenterBadgingEnabled(isBadgingEnabled) {
if (Platform.OS === 'android') {
RCTPushIOManager.setMessageCenterBadgingEnabled(isBadgingEnabled);
} else {
console.log("API not supported");
}
}
/**
*
* @param {*} areNotificationsStacked
*/
static setNotificationsStacked(areNotificationsStacked) {
if (Platform.OS === 'android') {
RCTPushIOManager.setNotificationsStacked(areNotificationsStacked);
} else {
console.log("API not supported");
}
}
static getNotificationStacked(callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.getNotificationStacked(callback);
} else {
console.log("API not supported");
}
}
static setDefaultSmallIcon(resourceId) {
if (Platform.OS === 'android') {
RCTPushIOManager.setDefaultSmallIcon(resourceId);
} else {
console.log("API not supported");
}
}
static setDefaultLargeIcon(resourceId) {
if (Platform.OS === 'android') {
RCTPushIOManager.setDefaultLargeIcon(resourceId);
} else {
console.log("API not supported");
}
}
/**
* Request the SDK to process and display notification using the provided {@link com.google.firebase.messaging.RemoteMessage}
*
* @param message
*/
static handleMessage(message) {
if (Platform.OS === 'android') {
RCTPushIOManager.handleMessage(message);
} else {
console.log("API not supported");
}
}
/**
* Removes all app-defined Interactive Notification categories from the SDK's cache.
*/
static clearInteractiveNotificationCategories() {
if (Platform.OS === 'android') {
RCTPushIOManager.clearInteractiveNotificationCategories();
} else {
console.log("API not supported");
}
}
/**
* Adds a new app-defined Interactive Notification category.
* @param {InteractiveNotificationCategory} notificationCategory
* @param {callback} callback
*/
static addInteractiveNotificationCategory(notificationCategory, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.addInteractiveNotificationCategory(notificationCategory, callback);
} else {
console.log("API not supported");
}
}
/**
* Removes app-defined Interactive Notification category.
* @param {string} categoryId
*/
static deleteInteractiveNotificationCategory(categoryId) {
if (Platform.OS === 'android') {
RCTPushIOManager.deleteInteractiveNotificationCategory(categoryId);
} else {
console.log("API not supported");
}
}
/**
* Gets a single Interactive Notification category for the given category ID.
* @param {string} categoryId
* @param {callback} callback
*/
static getInteractiveNotificationCategory(categoryId, callback) {
if (Platform.OS === 'android') {
RCTPushIOManager.getInteractiveNotificationCategory(categoryId, callback);
} else {
console.log("API not supported");
}
}
// iOS-Only APIs
/**
*
*/
static registerForRemoteNotifications() {
if (Platform.OS === 'ios') {
RCTPushIOManager.registerForRemoteNotifications();
} else {
console.log("API not supported");
}
}
/**
* registerForAllRemoteNotificationTypes Listener is added
* @param {callback} callback
*/
static registerForAllRemoteNotificationTypes(callback) {
if (Platform.OS === 'ios') {
RCTPushIOEventEmitter.addListener('registerForAllRemoteNotificationTypes', result => {
if (result.error) {
callback(result.error, result.response)
} else {
callback(null, result.response)
}
});
RCTPushIOManager.registerForAllRemoteNotificationTypes();
} else {
console.log("API not supported");
}
}
/**
* Asks user permissions for all push notifications types. i.e.: Sound/Badge/Alert types.
* If readyForRegistrationCompHandler is not set, then provided completionHandler is assigned to it, to let application have access when SDK receives deviceToken.
* Only available on iOS platform.
* @param {int} authOptions Notification auth types i.e.: Sound/Badge/Alert.
* @param {InteractiveNotificationCategory[]} categories categories Contains the notification categories definitions.
* @param {*} callback
*/
static registerForNotificationAuthorizations(authOptions, categories, callback) {
if (Platform.OS === 'ios') {
RCTPushIOManager.registerForNotificationAuthorizations(authOptions, categories, callback);
} else {
console.log("API not supported");
}
}
/**
* Asks user permissions for all push notifications types. i.e.: Sound/Badge/Alert types. You can pass the notification categories definitions to register.
*
* Only available on iOS platform.
*
* @param {InteractiveNotificationCategory[]} categories Contains the notification categories definitions.
* @param {callback} callback callback.
*/