react-native-insider 7.0.11 → 7.0.12

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.
package/RNInsider.podspec CHANGED
@@ -9,12 +9,12 @@ Pod::Spec.new do |s|
9
9
  s.authors = package_json['author']
10
10
  s.license = 'MIT'
11
11
  s.platform = :ios, '12.0'
12
- s.source = {:http => 'https://mobilesdk.useinsider.com/iOS/14.2.7/InsiderMobileIOSFramework.zip'}
12
+ s.source = {:http => 'https://mobilesdk.useinsider.com/iOS/14.2.8/InsiderMobileIOSFramework.zip'}
13
13
  s.source_files = 'ios/RNInsider/*.{h,m}'
14
14
  s.requires_arc = true
15
15
  s.static_framework = true
16
16
  s.dependency 'React'
17
- s.dependency 'InsiderMobile', '14.2.7'
17
+ s.dependency 'InsiderMobile', '14.2.8'
18
18
  s.dependency 'InsiderGeofence', '1.2.4'
19
19
  s.dependency 'InsiderHybrid', '1.7.6'
20
20
  end
@@ -42,7 +42,7 @@ repositories {
42
42
 
43
43
  dependencies {
44
44
  implementation "com.facebook.react:react-native:${getVersionFromPartner('reactNativeVersion', '+')}"
45
- implementation 'com.useinsider:insider:15.2.5'
45
+ implementation 'com.useinsider:insider:15.2.6'
46
46
  implementation 'com.useinsider:insiderhybrid:1.3.4'
47
47
 
48
48
  implementation 'androidx.security:security-crypto:1.1.0-alpha06'
@@ -22,6 +22,7 @@ import com.useinsider.insider.InsiderCallbackType;
22
22
  import com.useinsider.insider.InsiderIdentifiers;
23
23
  import com.useinsider.insider.InsiderUser;
24
24
  import com.useinsider.insider.InsiderProduct;
25
+ import com.useinsider.insider.CloseButtonPosition;
25
26
  import com.useinsider.insider.MessageCenterData;
26
27
  import com.useinsider.insider.RecommendationEngine;
27
28
  import com.useinsider.insiderhybrid.InsiderHybrid;
@@ -465,66 +466,108 @@ public class RNInsiderModule extends ReactContextBaseJavaModule {
465
466
  }
466
467
 
467
468
  @ReactMethod
468
- public void itemPurchased(String saleID, ReadableMap requiredFields, ReadableMap optionalFields, ReadableArray customParameters) {
469
+ public void itemPurchased(String saleID, ReadableMap requiredFields, ReadableMap optionalFields, ReadableArray customParameters, ReadableArray eventCustomParameters) {
469
470
  try {
470
471
  InsiderProduct product = RNUtils.parseProduct(requiredFields, optionalFields, customParameters);
471
- Insider.Instance.itemPurchased(saleID, product);
472
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(eventCustomParameters);
473
+
474
+ if (!mappedCustomParameters.isEmpty()) {
475
+ Insider.Instance.itemPurchased(saleID, product, mappedCustomParameters);
476
+ } else {
477
+ Insider.Instance.itemPurchased(saleID, product);
478
+ }
472
479
  } catch (Exception e) {
473
480
  Insider.Instance.putException(e);
474
481
  }
475
482
  }
476
483
 
477
484
  @ReactMethod
478
- public void itemAddedToCart(ReadableMap requiredFields, ReadableMap optionalFields, ReadableArray customParameters) {
485
+ public void itemAddedToCart(ReadableMap requiredFields, ReadableMap optionalFields, ReadableArray customParameters, ReadableArray eventCustomParameters) {
479
486
  try {
480
487
  InsiderProduct product = RNUtils.parseProduct(requiredFields, optionalFields, customParameters);
481
- Insider.Instance.itemAddedToCart(product);
488
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(eventCustomParameters);
489
+
490
+ if (!mappedCustomParameters.isEmpty()) {
491
+ Insider.Instance.itemAddedToCart(product, mappedCustomParameters);
492
+ } else {
493
+ Insider.Instance.itemAddedToCart(product);
494
+ }
482
495
  } catch (Exception e) {
483
496
  Insider.Instance.putException(e);
484
497
  }
485
498
  }
486
499
 
487
500
  @ReactMethod
488
- public void itemRemovedFromCart(String productID) {
501
+ public void itemRemovedFromCart(String productID, ReadableArray customParameters) {
489
502
  try {
490
- Insider.Instance.itemRemovedFromCart(productID);
503
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(customParameters);
504
+
505
+ if (!mappedCustomParameters.isEmpty()) {
506
+ Insider.Instance.itemRemovedFromCart(productID, mappedCustomParameters);
507
+ } else {
508
+ Insider.Instance.itemRemovedFromCart(productID);
509
+ }
491
510
  } catch (Exception e) {
492
511
  Insider.Instance.putException(e);
493
512
  }
494
513
  }
495
514
 
496
515
  @ReactMethod
497
- public void cartCleared() {
516
+ public void cartCleared(ReadableArray customParameters) {
498
517
  try {
499
- Insider.Instance.cartCleared();
518
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(customParameters);
519
+
520
+ if (!mappedCustomParameters.isEmpty()) {
521
+ Insider.Instance.cartCleared(mappedCustomParameters);
522
+ } else {
523
+ Insider.Instance.cartCleared();
524
+ }
500
525
  } catch (Exception e) {
501
526
  Insider.Instance.putException(e);
502
527
  }
503
528
  }
504
529
 
505
530
  @ReactMethod
506
- public void itemAddedToWishlist(ReadableMap requiredFields, ReadableMap optionalFields, ReadableArray customParameters) {
531
+ public void itemAddedToWishlist(ReadableMap requiredFields, ReadableMap optionalFields, ReadableArray customParameters, ReadableArray eventCustomParameters) {
507
532
  try {
508
533
  InsiderProduct product = RNUtils.parseProduct(requiredFields, optionalFields, customParameters);
509
- Insider.Instance.itemAddedToWishlist(product);
534
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(eventCustomParameters);
535
+
536
+ if (!mappedCustomParameters.isEmpty()) {
537
+ Insider.Instance.itemAddedToWishlist(product, mappedCustomParameters);
538
+ } else {
539
+ Insider.Instance.itemAddedToWishlist(product);
540
+ }
510
541
  } catch (Exception e) {
511
542
  Insider.Instance.putException(e);
512
543
  }
513
544
  }
514
545
 
515
546
  @ReactMethod
516
- public void itemRemovedFromWishlist(String productID) {
547
+ public void itemRemovedFromWishlist(String productID, ReadableArray customParameters) {
517
548
  try {
518
- Insider.Instance.itemRemovedFromWishlist(productID);
549
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(customParameters);
550
+
551
+ if (!mappedCustomParameters.isEmpty()) {
552
+ Insider.Instance.itemRemovedFromWishlist(productID, mappedCustomParameters);
553
+ } else {
554
+ Insider.Instance.itemRemovedFromWishlist(productID);
555
+ }
519
556
  } catch (Exception e) {
520
557
  Insider.Instance.putException(e);
521
558
  }
522
559
  }
523
560
 
524
561
  @ReactMethod
525
- public void wishlistCleared() {
562
+ public void wishlistCleared(ReadableArray customParameters) {
526
563
  try {
527
- Insider.Instance.wishlistCleared();
564
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(customParameters);
565
+
566
+ if (!mappedCustomParameters.isEmpty()) {
567
+ Insider.Instance.wishlistCleared(mappedCustomParameters);
568
+ } else {
569
+ Insider.Instance.wishlistCleared();
570
+ }
528
571
  } catch (Exception e) {
529
572
  Insider.Instance.putException(e);
530
573
  }
@@ -686,65 +729,97 @@ public class RNInsiderModule extends ReactContextBaseJavaModule {
686
729
 
687
730
 
688
731
  @ReactMethod
689
- public void visitHomePage() {
732
+ public void visitHomePage(ReadableArray customParameters) {
690
733
  try {
691
- Insider.Instance.visitHomePage();
734
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(customParameters);
735
+
736
+ if (!mappedCustomParameters.isEmpty()) {
737
+ Insider.Instance.visitHomePage(mappedCustomParameters);
738
+ } else {
739
+ Insider.Instance.visitHomePage();
740
+ }
692
741
  } catch (Exception e) {
693
742
  Insider.Instance.putException(e);
694
743
  }
695
744
  }
696
745
 
697
746
  @ReactMethod
698
- public void visitListingPage(ReadableArray taxonomy) {
747
+ public void visitListingPage(ReadableArray taxonomy, ReadableArray customParameters) {
699
748
  try {
700
749
  String[] taxonomies = RNUtils.convertReadableArrayToStringArray(taxonomy);
701
- Insider.Instance.visitListingPage(taxonomies);
750
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(customParameters);
751
+
752
+ if (!mappedCustomParameters.isEmpty()) {
753
+ Insider.Instance.visitListingPage(taxonomies, mappedCustomParameters);
754
+ } else {
755
+ Insider.Instance.visitListingPage(taxonomies);
756
+ }
702
757
  } catch (Exception e) {
703
758
  Insider.Instance.putException(e);
704
759
  }
705
760
  }
706
761
 
707
762
  @ReactMethod
708
- public void visitProductDetailPage(ReadableMap requiredFields, ReadableMap optionalFields, ReadableArray customParameters) {
763
+ public void visitProductDetailPage(ReadableMap requiredFields, ReadableMap optionalFields, ReadableArray customParameters, ReadableArray eventCustomParameters) {
709
764
  try {
710
765
  InsiderProduct product = RNUtils.parseProduct(requiredFields, optionalFields, customParameters);
711
- Insider.Instance.visitProductDetailPage(product);
766
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(eventCustomParameters);
767
+
768
+ if (!mappedCustomParameters.isEmpty()) {
769
+ Insider.Instance.visitProductDetailPage(product, mappedCustomParameters);
770
+ } else {
771
+ Insider.Instance.visitProductDetailPage(product);
772
+ }
712
773
  } catch (Exception e) {
713
774
  Insider.Instance.putException(e);
714
775
  }
715
776
  }
716
777
 
717
778
  @ReactMethod
718
- public void visitCartPage(ReadableArray products) {
779
+ public void visitCartPage(ReadableArray products, ReadableArray customParameters) {
719
780
  try {
720
781
  InsiderProduct[] ips = new InsiderProduct[products.size()];
721
782
  for (int i = 0; i < products.size(); i++) {
722
783
  ReadableMap productMap = products.getMap(i);
723
784
  ReadableMap requiredFields = productMap.getMap("requiredFields");
724
785
  ReadableMap optionalFields = productMap.getMap("optionalFields");
725
- ReadableArray customParameters = productMap.getArray("customParameters");
726
- InsiderProduct product = RNUtils.parseProduct(requiredFields, optionalFields, customParameters);
786
+ ReadableArray productCustomParameters = productMap.getArray("customParameters");
787
+ InsiderProduct product = RNUtils.parseProduct(requiredFields, optionalFields, productCustomParameters);
727
788
  ips[i] = product;
728
789
  }
729
- Insider.Instance.visitCartPage(ips);
790
+
791
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(customParameters);
792
+
793
+ if (!mappedCustomParameters.isEmpty()) {
794
+ Insider.Instance.visitCartPage(ips, mappedCustomParameters);
795
+ } else {
796
+ Insider.Instance.visitCartPage(ips);
797
+ }
730
798
  } catch (Exception e) {
731
799
  Insider.Instance.putException(e);
732
800
  }
733
801
  }
734
802
 
735
803
  @ReactMethod
736
- public void visitWishlistPage(ReadableArray products) {
804
+ public void visitWishlistPage(ReadableArray products, ReadableArray customParameters) {
737
805
  try {
738
806
  InsiderProduct[] ips = new InsiderProduct[products.size()];
739
807
  for (int i = 0; i < products.size(); i++) {
740
808
  ReadableMap productMap = products.getMap(i);
741
809
  ReadableMap requiredFields = productMap.getMap("requiredFields");
742
810
  ReadableMap optionalFields = productMap.getMap("optionalFields");
743
- ReadableArray customParameters = productMap.getArray("customParameters");
744
- InsiderProduct product = RNUtils.parseProduct(requiredFields, optionalFields, customParameters);
811
+ ReadableArray productCustomParameters = productMap.getArray("customParameters");
812
+ InsiderProduct product = RNUtils.parseProduct(requiredFields, optionalFields, productCustomParameters);
745
813
  ips[i] = product;
746
814
  }
747
- Insider.Instance.visitWishlistPage(ips);
815
+
816
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(customParameters);
817
+
818
+ if (!mappedCustomParameters.isEmpty()) {
819
+ Insider.Instance.visitWishlistPage(ips, mappedCustomParameters);
820
+ } else {
821
+ Insider.Instance.visitWishlistPage(ips);
822
+ }
748
823
  } catch (Exception e) {
749
824
  Insider.Instance.putException(e);
750
825
  }
@@ -880,9 +955,26 @@ public class RNInsiderModule extends ReactContextBaseJavaModule {
880
955
  }
881
956
 
882
957
  @ReactMethod
883
- public void signUpConfirmation() {
958
+ public void signUpConfirmation(ReadableArray customParameters) {
959
+ try {
960
+ Map<String, Object> mappedCustomParameters = RNUtils.parseCustomParameters(customParameters);
961
+
962
+ if (!mappedCustomParameters.isEmpty()) {
963
+ Insider.Instance.signUpConfirmation(mappedCustomParameters);
964
+ } else {
965
+ Insider.Instance.signUpConfirmation();
966
+ }
967
+ } catch (Exception e) {
968
+ Insider.Instance.putException(e);
969
+ }
970
+ }
971
+
972
+ @ReactMethod
973
+ public void setInternalBrowserCloseButtonPosition(String position) {
884
974
  try {
885
- Insider.Instance.signUpConfirmation();
975
+ if (position == null) return;
976
+ CloseButtonPosition enumPosition = CloseButtonPosition.valueOf(position);
977
+ Insider.Instance.setInternalBrowserCloseButtonPosition(enumPosition);
886
978
  } catch (Exception e) {
887
979
  Insider.Instance.putException(e);
888
980
  }
@@ -379,4 +379,73 @@ public class RNUtils {
379
379
 
380
380
  return product;
381
381
  }
382
+
383
+ public static Map<String, Object> parseCustomParameters(ReadableArray customParameters) {
384
+ Map<String, Object> mappedCustomParameters = new HashMap<>();
385
+ try {
386
+ if (customParameters == null) {
387
+ return mappedCustomParameters;
388
+ }
389
+
390
+ for (int i = 0; i < customParameters.size(); i++) {
391
+ ReadableMap parameter = customParameters.getMap(i);
392
+ if (parameter == null) continue;
393
+
394
+ String type = parameter.hasKey("type") ? parameter.getString("type") : null;
395
+ String key = parameter.hasKey("key") ? parameter.getString("key") : null;
396
+ if (type == null || key == null) continue;
397
+
398
+ switch (type) {
399
+ case "string":
400
+ if (parameter.hasKey("value") && !parameter.isNull("value")) {
401
+ mappedCustomParameters.put(key, parameter.getString("value"));
402
+ }
403
+ break;
404
+ case "integer":
405
+ if (parameter.hasKey("value") && !parameter.isNull("value")) {
406
+ mappedCustomParameters.put(key, parameter.getInt("value"));
407
+ }
408
+ break;
409
+ case "double":
410
+ if (parameter.hasKey("value") && !parameter.isNull("value")) {
411
+ mappedCustomParameters.put(key, parameter.getDouble("value"));
412
+ }
413
+ break;
414
+ case "boolean":
415
+ if (parameter.hasKey("value") && !parameter.isNull("value")) {
416
+ mappedCustomParameters.put(key, parameter.getBoolean("value"));
417
+ }
418
+ break;
419
+ case "date":
420
+ if (parameter.hasKey("value") && !parameter.isNull("value")) {
421
+ double epochMillis = parameter.getDouble("value");
422
+ Date dateValue = new Date((long) epochMillis);
423
+ mappedCustomParameters.put(key, dateValue);
424
+ }
425
+ break;
426
+ case "numeric_array":
427
+ if (parameter.hasKey("value") && !parameter.isNull("value")) {
428
+ ReadableArray arrayValue = parameter.getArray("value");
429
+ Number[] numberArray = convertReadableArrayToNumericArray(arrayValue);
430
+ if (numberArray != null) {
431
+ mappedCustomParameters.put(key, numberArray);
432
+ }
433
+ }
434
+ break;
435
+ case "string_array":
436
+ if (parameter.hasKey("value") && !parameter.isNull("value")) {
437
+ ReadableArray arrayValue = parameter.getArray("value");
438
+ String[] stringArray = convertReadableArrayToStringArray(arrayValue);
439
+ if (stringArray != null) {
440
+ mappedCustomParameters.put(key, stringArray);
441
+ }
442
+ }
443
+ break;
444
+ }
445
+ }
446
+ } catch (Exception e) {
447
+ Insider.Instance.putException(e);
448
+ }
449
+ return mappedCustomParameters;
450
+ }
382
451
  }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: ['@react-native/babel-preset'],
3
+ };
package/index.d.ts CHANGED
@@ -1,9 +1,20 @@
1
- import type RNInsiderProduct from '.src/InsiderProduct';
1
+ import type RNInsiderProduct from './src/InsiderProduct';
2
2
  import type RNInsiderEvent from './src/InsiderEvent';
3
3
  import type RNInsiderUser from './src/InsiderUser';
4
4
 
5
+ export type CustomParameters = {
6
+ [key: string]: string | number | boolean | Date | number[] | string[];
7
+ };
8
+
5
9
  declare module 'react-native-insider' {
10
+ export interface InsiderCloseButtonPosition {
11
+ LEFT: string;
12
+ RIGHT: string;
13
+ NONE: string;
14
+ }
15
+
6
16
  export default class RNInsider {
17
+ static closeButtonPosition: InsiderCloseButtonPosition;
7
18
  static init(partnerName: string, appGroup: string, insiderCallback: Function): void;
8
19
  static initWithCustomEndpoint(partnerName: string, appGroup: string, endpoint: string, insiderCallback: Function): void;
9
20
  static reinitWithPartnerName(partnerName: string): void;
@@ -20,13 +31,13 @@ declare module 'react-native-insider' {
20
31
  price: number,
21
32
  currency: string
22
33
  ): RNInsiderProduct;
23
- static itemPurchased(uniqueSaleID: string, product: RNInsiderProduct): void;
24
- static itemAddedToCart(product: RNInsiderProduct): void;
25
- static itemRemovedFromCart(productID: string): void;
26
- static cartCleared(): void;
27
- static itemAddedToWishlist(product: RNInsiderProduct): void;
28
- static itemRemovedFromWishlist(productID: string): void;
29
- static wishlistCleared(): void;
34
+ static itemPurchased(uniqueSaleID: string, product: RNInsiderProduct, customParameters?: CustomParameters): void;
35
+ static itemAddedToCart(product: RNInsiderProduct, customParameters?: CustomParameters): void;
36
+ static itemRemovedFromCart(productID: string, customParameters?: CustomParameters): void;
37
+ static cartCleared(customParameters?: CustomParameters): void;
38
+ static itemAddedToWishlist(product: RNInsiderProduct, customParameters?: CustomParameters): void;
39
+ static itemRemovedFromWishlist(productID: string, customParameters?: CustomParameters): void;
40
+ static wishlistCleared(customParameters?: CustomParameters): void;
30
41
  static getMessageCenterData(
31
42
  limit: number,
32
43
  startDate: Date,
@@ -40,16 +51,16 @@ declare module 'react-native-insider' {
40
51
  callback: (recommendation: any) => void
41
52
  ): void;
42
53
  static getSmartRecommendationWithProduct(
43
- product: RNInsiderProduct,
44
- recommendationID: number,
45
- locale: string,
54
+ product: RNInsiderProduct,
55
+ recommendationID: number,
56
+ locale: string,
46
57
  callback: (recommendation: any) => void
47
58
  ): void;
48
59
  static getSmartRecommendationWithProductIDs(
49
- productIDs: string[],
50
- recommendationID: number,
51
- locale: string,
52
- currency: string,
60
+ productIDs: string[],
61
+ recommendationID: number,
62
+ locale: string,
63
+ currency: string,
53
64
  callback: (recommendation: any) => void
54
65
  ): void;
55
66
  static clickSmartRecommendationProduct(recommendationID: number, product: RNInsiderProduct): void;
@@ -60,40 +71,40 @@ declare module 'react-native-insider' {
60
71
  callback: (content: string) => void
61
72
  ): void;
62
73
  static getContentBoolWithName(
63
- variableName: string,
64
- defaultValue: boolean,
65
- contentOptimizerDataType: number,
74
+ variableName: string,
75
+ defaultValue: boolean,
76
+ contentOptimizerDataType: number,
66
77
  callback: (content: boolean) => void
67
78
  ): void;
68
79
  static getContentIntWithName(
69
- variableName: string,
70
- defaultValue: number,
71
- contentOptimizerDataType: number,
80
+ variableName: string,
81
+ defaultValue: number,
82
+ contentOptimizerDataType: number,
72
83
  callback: (content: number) => void
73
84
  ): void;
74
85
  static getContentStringWithoutCache(
75
- variableName: string,
76
- defaultValue: string,
77
- contentOptimizerDataType: number,
78
- callback: (content: string) => void
86
+ variableName: string,
87
+ defaultValue: string,
88
+ contentOptimizerDataType: number,
89
+ callback: (content: string) => void
79
90
  ): void;
80
91
  static getContentBoolWithoutCache(
81
- variableName: string,
82
- defaultValue: boolean,
83
- contentOptimizerDataType: number,
84
- callback: (content: boolean) => void
92
+ variableName: string,
93
+ defaultValue: boolean,
94
+ contentOptimizerDataType: number,
95
+ callback: (content: boolean) => void
85
96
  ): void;
86
97
  static getContentIntWithoutCache(
87
- variableName: string,
88
- defaultValue: number,
89
- contentOptimizerDataType: number,
90
- callback: (content: number) => void
98
+ variableName: string,
99
+ defaultValue: number,
100
+ contentOptimizerDataType: number,
101
+ callback: (content: number) => void
91
102
  ): void;
92
- static visitHomePage(): void;
93
- static visitListingPage(taxonomy: Array<string>): void;
94
- static visitProductDetailPage(product: RNInsiderProduct): void;
95
- static visitCartPage(products: Array<RNInsiderProduct>): void;
96
- static visitWishlistPage(products: Array<RNInsiderProduct>): void;
103
+ static visitHomePage(customParameters?: CustomParameters): void;
104
+ static visitListingPage(taxonomy: Array<string>, customParameters?: CustomParameters): void;
105
+ static visitProductDetailPage(product: RNInsiderProduct, customParameters?: CustomParameters): void;
106
+ static visitCartPage(products: Array<RNInsiderProduct>, customParameters?: CustomParameters): void;
107
+ static visitWishlistPage(products: Array<RNInsiderProduct>, customParameters?: CustomParameters): void;
97
108
  static startTrackingGeofence(): void;
98
109
  static setAllowsBackgroundLocationUpdates(allowsBackgroundLocationUpdates: boolean): void;
99
110
  static handleNotification(notification: any): void;
@@ -105,7 +116,8 @@ declare module 'react-native-insider' {
105
116
  static enableLocationCollection(consentStatus: boolean): void;
106
117
  static enableIpCollection(consentStatus: boolean): void;
107
118
  static enableCarrierCollection(consentStatus: boolean): void;
108
- static signUpConfirmation(): void;
119
+ static signUpConfirmation(customParameters?: CustomParameters): void;
120
+ static setInternalBrowserCloseButtonPosition(position: string): void;
109
121
  static reenableTemplatesForIOS(): void;
110
122
  static disableTemplatesForIOS(): void;
111
123
  static setForegroundPushCallback(callback: (notification: any) => void): void;
package/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Platform, NativeModules, NativeEventEmitter } from 'react-native';
2
2
 
3
- import { shouldNotProceed, generateJSONErrorString, checkParameters, showParameterWarningLog } from './src/Util';
3
+ import { shouldNotProceed, generateJSONErrorString, checkParameters, showParameterWarningLog, parseObjectWithTypes } from './src/Util';
4
4
  import RNInsiderEvent from './src/InsiderEvent';
5
5
  import RNInsiderUser from './src/InsiderUser';
6
6
  import RNInsiderProduct from './src/InsiderProduct';
7
+ import CloseButtonPosition from './src/CloseButtonPosition';
7
8
 
8
9
  var packageJSON = require('./package.json');
9
10
 
@@ -41,6 +42,8 @@ function registerInsiderCallback(insiderCallback) {
41
42
  }
42
43
 
43
44
  export default class RNInsider {
45
+ static closeButtonPosition = CloseButtonPosition;
46
+
44
47
  static init(partnerName, appGroup, insiderCallback) {
45
48
  if (shouldNotProceed()) return;
46
49
  if (checkParameters([{ type: 'string', value: partnerName }, { type: 'string', value: appGroup }, { type: 'function', value: insiderCallback }])) {
@@ -171,7 +174,7 @@ export default class RNInsider {
171
174
  return new RNInsiderProduct(productID, name, taxonomy, imageURL, price, currency);
172
175
  }
173
176
 
174
- static itemPurchased(uniqueSaleID, product) {
177
+ static itemPurchased(uniqueSaleID, product, customParameters) {
175
178
  if (shouldNotProceed()) return;
176
179
  if (checkParameters([
177
180
  { type: 'string', value: uniqueSaleID },
@@ -184,69 +187,76 @@ export default class RNInsider {
184
187
  return;
185
188
  }
186
189
  try {
187
- Insider.itemPurchased(uniqueSaleID, product.requiredFields, product.optionalFields, product.customParameters);
190
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
191
+ Insider.itemPurchased(uniqueSaleID, product.requiredFields, product.optionalFields, product.customParameters, mappedCustomParameters);
188
192
  } catch (error) {
189
193
  Insider.putErrorLog(generateJSONErrorString(error));
190
194
  }
191
195
  }
192
196
 
193
- static itemAddedToCart(product) {
197
+ static itemAddedToCart(product, customParameters) {
194
198
  if (shouldNotProceed()) return;
195
199
  if (checkParameters([{ type: 'object', value: product }])) {
196
200
  showParameterWarningLog("itemAddedToCart", [{ type: 'object', value: product }]);
197
201
  return;
198
202
  }
199
203
  try {
200
- Insider.itemAddedToCart(product.requiredFields, product.optionalFields, product.customParameters);
204
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
205
+ Insider.itemAddedToCart(product.requiredFields, product.optionalFields, product.customParameters, mappedCustomParameters);
201
206
  } catch (error) {
202
207
  Insider.putErrorLog(generateJSONErrorString(error));
203
208
  }
204
209
  }
205
210
 
206
- static itemRemovedFromCart(productID) {
211
+ static itemRemovedFromCart(productID, customParameters) {
207
212
  if (shouldNotProceed()) return;
208
213
  if (checkParameters([{ type: 'string', value: productID }])) {
209
214
  showParameterWarningLog("itemRemovedFromCart", [{ type: 'string', value: productID }]);
210
215
  return;
211
216
  }
212
217
  try {
213
- Insider.itemRemovedFromCart(productID);
218
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
219
+ Insider.itemRemovedFromCart(productID, mappedCustomParameters);
214
220
  } catch (error) {
215
221
  Insider.putErrorLog(generateJSONErrorString(error));
216
222
  }
217
223
  }
218
224
 
219
- static cartCleared() {
225
+ static cartCleared(customParameters) {
220
226
  if (shouldNotProceed()) return;
221
227
  try {
222
- Insider.cartCleared();
228
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
229
+ Insider.cartCleared(mappedCustomParameters);
223
230
  } catch (error) {
224
231
  Insider.putErrorLog(generateJSONErrorString(error));
225
232
  }
226
233
  }
227
234
 
228
- static itemAddedToWishlist(product) {
235
+ static itemAddedToWishlist(product, customParameters) {
229
236
  if (shouldNotProceed() || product == null) return;
230
237
  try {
231
- Insider.itemAddedToWishlist(product.requiredFields, product.optionalFields, product.customParameters);
238
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
239
+ Insider.itemAddedToWishlist(product.requiredFields, product.optionalFields, product.customParameters, mappedCustomParameters);
232
240
  } catch (error) {
233
241
  Insider.putErrorLog(generateJSONErrorString(error));
234
242
  }
235
243
  }
236
244
 
237
- static itemRemovedFromWishlist(productID) {
245
+ static itemRemovedFromWishlist(productID, customParameters) {
238
246
  if (shouldNotProceed() || productID == null) return;
239
247
  try {
240
- Insider.itemRemovedFromWishlist(productID);
248
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
249
+ Insider.itemRemovedFromWishlist(productID, mappedCustomParameters);
241
250
  } catch (error) {
242
251
  Insider.putErrorLog(generateJSONErrorString(error));
243
252
  }
244
253
  }
245
254
 
246
- static wishlistCleared() {
255
+ static wishlistCleared(customParameters) {
247
256
  if (shouldNotProceed()) return;
248
257
  try {
249
- Insider.wishlistCleared();
258
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
259
+ Insider.wishlistCleared(mappedCustomParameters);
250
260
  } catch (error) {
251
261
  Insider.putErrorLog(generateJSONErrorString(error));
252
262
  }
@@ -526,42 +536,45 @@ export default class RNInsider {
526
536
 
527
537
 
528
538
  // Visit Pages
529
- static visitHomePage() {
539
+ static visitHomePage(customParameters) {
530
540
  if (shouldNotProceed()) return;
531
541
  try {
532
- Insider.visitHomePage();
542
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
543
+ Insider.visitHomePage(mappedCustomParameters);
533
544
  } catch (error) {
534
545
  Insider.putErrorLog(generateJSONErrorString(error));
535
546
  }
536
547
  }
537
548
 
538
- static visitListingPage(taxonomy) {
549
+ static visitListingPage(taxonomy, customParameters) {
539
550
  if (shouldNotProceed()) return;
540
551
  if (checkParameters([{ type: 'object', value: taxonomy }])) {
541
552
  showParameterWarningLog("visitListingPage", [{ type: 'object', value: taxonomy }]);
542
553
  return;
543
554
  }
544
555
  try {
545
- Insider.visitListingPage(taxonomy);
556
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
557
+ Insider.visitListingPage(taxonomy, mappedCustomParameters);
546
558
  } catch (error) {
547
559
  Insider.putErrorLog(generateJSONErrorString(error));
548
560
  }
549
561
  }
550
562
 
551
- static visitProductDetailPage(product) {
563
+ static visitProductDetailPage(product, customParameters) {
552
564
  if (shouldNotProceed()) return;
553
565
  if (checkParameters([{ type: 'object', value: product }])) {
554
566
  showParameterWarningLog("visitProductDetailPage", [{ type: 'object', value: product }]);
555
567
  return;
556
568
  }
557
569
  try {
558
- Insider.visitProductDetailPage(product.requiredFields, product.optionalFields, product.customParameters);
570
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
571
+ Insider.visitProductDetailPage(product.requiredFields, product.optionalFields, product.customParameters, mappedCustomParameters);
559
572
  } catch (error) {
560
573
  Insider.putErrorLog(generateJSONErrorString(error));
561
574
  }
562
575
  }
563
576
 
564
- static visitCartPage(products) {
577
+ static visitCartPage(products, customParameters) {
565
578
  if (shouldNotProceed()) return;
566
579
  if (checkParameters([{ type: 'object', value: products }])) {
567
580
  showParameterWarningLog("visitCartPage", [{ type: 'object', value: products }]);
@@ -573,13 +586,14 @@ export default class RNInsider {
573
586
  optionalFields: product.optionalFields,
574
587
  customParameters: product.customParameters
575
588
  }));
576
- Insider.visitCartPage(mappedProducts);
589
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
590
+ Insider.visitCartPage(mappedProducts, mappedCustomParameters);
577
591
  } catch (error) {
578
592
  Insider.putErrorLog(generateJSONErrorString(error));
579
593
  }
580
594
  }
581
595
 
582
- static visitWishlistPage(products) {
596
+ static visitWishlistPage(products, customParameters) {
583
597
  if (shouldNotProceed() || products == null) return;
584
598
  if (checkParameters([{ type: 'object', value: products }])) {
585
599
  showParameterWarningLog("visitWishlistPage", [{ type: 'object', value: products }]);
@@ -591,7 +605,8 @@ export default class RNInsider {
591
605
  optionalFields: product.optionalFields,
592
606
  customParameters: product.customParameters
593
607
  }));
594
- Insider.visitWishlistPage(mappedProducts);
608
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
609
+ Insider.visitWishlistPage(mappedProducts, mappedCustomParameters);
595
610
  } catch (error) {
596
611
  Insider.putErrorLog(generateJSONErrorString(error));
597
612
  }
@@ -730,11 +745,25 @@ export default class RNInsider {
730
745
  }
731
746
  }
732
747
 
733
- static signUpConfirmation() {
748
+ static signUpConfirmation(customParameters) {
734
749
  if (shouldNotProceed()) return;
735
750
 
736
751
  try {
737
- Insider.signUpConfirmation();
752
+ const mappedCustomParameters = parseObjectWithTypes(customParameters);
753
+ Insider.signUpConfirmation(mappedCustomParameters);
754
+ } catch (error) {
755
+ Insider.putErrorLog(generateJSONErrorString(error));
756
+ }
757
+ }
758
+
759
+ static setInternalBrowserCloseButtonPosition(position) {
760
+ if (shouldNotProceed() || Platform.OS !== platformType.android) return;
761
+ if (checkParameters([{ type: 'string', value: position }])) {
762
+ showParameterWarningLog("setInternalBrowserCloseButtonPosition", [{ type: 'string', value: position }]);
763
+ return;
764
+ }
765
+ try {
766
+ Insider.setInternalBrowserCloseButtonPosition(position);
738
767
  } catch (error) {
739
768
  Insider.putErrorLog(generateJSONErrorString(error));
740
769
  }
@@ -376,69 +376,117 @@ RCT_EXPORT_METHOD(setMobileAppAccess:(BOOL)mobileAppAccess) {
376
376
  }
377
377
  }
378
378
 
379
- RCT_EXPORT_METHOD(signUpConfirmation) {
379
+ RCT_EXPORT_METHOD(signUpConfirmation:(NSArray *)customParameters) {
380
380
  @try {
381
- [Insider signUpConfirmation];
381
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:customParameters];
382
+
383
+ if (mappedCustomParameters.count > 0) {
384
+ [Insider signUpConfirmationWithCustomParameters:mappedCustomParameters];
385
+ } else {
386
+ [Insider signUpConfirmation];
387
+ }
382
388
  } @catch (NSException *e){
383
389
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
384
390
  }
385
391
  }
386
392
 
387
393
  // Insider Product
388
- RCT_EXPORT_METHOD(itemPurchased:(NSString *)saleID requiredFields:(NSDictionary *)requiredFields optionalFields:(NSDictionary *)optionalFields customParameters:(NSArray *)customParameters) {
394
+ RCT_EXPORT_METHOD(itemPurchased:(NSString *)saleID requiredFields:(NSDictionary *)requiredFields optionalFields:(NSDictionary *)optionalFields customParameters:(NSArray *)customParameters eventCustomParameters:(NSArray *)eventCustomParameters) {
389
395
  @try {
390
396
  InsiderProduct *product = [RNUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
391
- [Insider itemPurchasedWithSaleID:saleID product:product];
397
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:eventCustomParameters];
398
+
399
+ if (mappedCustomParameters.count > 0) {
400
+ [Insider itemPurchasedWithSaleID:saleID product:product customParameters:mappedCustomParameters];
401
+ } else {
402
+ [Insider itemPurchasedWithSaleID:saleID product:product];
403
+ }
392
404
  } @catch (NSException *e){
393
405
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
394
406
  }
395
407
  }
396
408
 
397
- RCT_EXPORT_METHOD(itemAddedToCart:(NSDictionary *)requiredFields optionalFields:(NSDictionary *)optionalFields customParameters:(NSArray *)customParameters) {
409
+ RCT_EXPORT_METHOD(itemAddedToCart:(NSDictionary *)requiredFields optionalFields:(NSDictionary *)optionalFields customParameters:(NSArray *)customParameters eventCustomParameters:(NSArray *)eventCustomParameters) {
398
410
  @try {
399
411
  InsiderProduct *product = [RNUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
400
- [Insider itemAddedToCartWithProduct:product];
412
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:eventCustomParameters];
413
+
414
+ if (mappedCustomParameters.count > 0) {
415
+ [Insider itemAddedToCartWithProduct:product customParameters:mappedCustomParameters];
416
+ } else {
417
+ [Insider itemAddedToCartWithProduct:product];
418
+ }
401
419
  } @catch (NSException *e){
402
420
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
403
421
  }
404
422
  }
405
423
 
406
- RCT_EXPORT_METHOD(itemRemovedFromCart:(NSString *)productID) {
424
+ RCT_EXPORT_METHOD(itemRemovedFromCart:(NSString *)productID customParameters:(NSArray *)customParameters) {
407
425
  @try {
408
- [Insider itemRemovedFromCartWithProductID:productID];
426
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:customParameters];
427
+
428
+ if (mappedCustomParameters.count > 0) {
429
+ [Insider itemRemovedFromCartWithProductID:productID customParameters:mappedCustomParameters];
430
+ } else {
431
+ [Insider itemRemovedFromCartWithProductID:productID];
432
+ }
409
433
  } @catch (NSException *e){
410
434
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
411
435
  }
412
436
  }
413
437
 
414
- RCT_EXPORT_METHOD(cartCleared) {
438
+ RCT_EXPORT_METHOD(cartCleared:(NSArray *)customParameters) {
415
439
  @try {
416
- [Insider cartCleared];
440
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:customParameters];
441
+
442
+ if (mappedCustomParameters.count > 0) {
443
+ [Insider cartClearedWithCustomParameters:mappedCustomParameters];
444
+ } else {
445
+ [Insider cartCleared];
446
+ }
417
447
  } @catch (NSException *e){
418
448
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
419
449
  }
420
450
  }
421
451
 
422
- RCT_EXPORT_METHOD(itemAddedToWishlist:(NSDictionary *)requiredFields optionalFields:(NSDictionary *)optionalFields customParameters:(NSArray *)customParameters) {
452
+ RCT_EXPORT_METHOD(itemAddedToWishlist:(NSDictionary *)requiredFields optionalFields:(NSDictionary *)optionalFields customParameters:(NSArray *)customParameters eventCustomParameters:(NSArray *)eventCustomParameters) {
423
453
  @try {
424
454
  InsiderProduct *product = [RNUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
425
- [Insider itemAddedToWishlistWithProduct:product];
455
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:eventCustomParameters];
456
+
457
+ if (mappedCustomParameters.count > 0) {
458
+ [Insider itemAddedToWishlistWithProduct:product customParameters:mappedCustomParameters];
459
+ } else {
460
+ [Insider itemAddedToWishlistWithProduct:product];
461
+ }
426
462
  } @catch (NSException *e){
427
463
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
428
464
  }
429
465
  }
430
466
 
431
- RCT_EXPORT_METHOD(itemRemovedFromWishlist:(NSString *)productID) {
467
+ RCT_EXPORT_METHOD(itemRemovedFromWishlist:(NSString *)productID customParameters:(NSArray *)customParameters) {
432
468
  @try {
433
- [Insider itemRemovedFromWishlistWithProductID:productID];
469
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:customParameters];
470
+
471
+ if (mappedCustomParameters.count > 0) {
472
+ [Insider itemRemovedFromWishlistWithProductID:productID customParameters:mappedCustomParameters];
473
+ } else {
474
+ [Insider itemRemovedFromWishlistWithProductID:productID];
475
+ }
434
476
  } @catch (NSException *e){
435
477
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
436
478
  }
437
479
  }
438
480
 
439
- RCT_EXPORT_METHOD(wishlistCleared) {
481
+ RCT_EXPORT_METHOD(wishlistCleared:(NSArray *)customParameters) {
440
482
  @try {
441
- [Insider wishlistCleared];
483
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:customParameters];
484
+
485
+ if (mappedCustomParameters.count > 0) {
486
+ [Insider wishlistClearedWithCustomParameters:mappedCustomParameters];
487
+ } else {
488
+ [Insider wishlistCleared];
489
+ }
442
490
  } @catch (NSException *e){
443
491
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
444
492
  }
@@ -544,58 +592,90 @@ RCT_EXPORT_METHOD(getContentIntWithoutCache:(NSString *)variableName defaultValu
544
592
  }
545
593
  }
546
594
 
547
- RCT_EXPORT_METHOD(visitHomePage) {
595
+ RCT_EXPORT_METHOD(visitHomePage:(NSArray *)customParameters) {
548
596
  @try {
549
- [Insider visitHomepage];
597
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:customParameters];
598
+
599
+ if (mappedCustomParameters.count > 0) {
600
+ [Insider visitHomepageWithCustomParameters:mappedCustomParameters];
601
+ } else {
602
+ [Insider visitHomepage];
603
+ }
550
604
  } @catch (NSException *e) {
551
605
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
552
606
  }
553
607
  }
554
608
 
555
- RCT_EXPORT_METHOD(visitListingPage:(NSArray *)taxonomy) {
609
+ RCT_EXPORT_METHOD(visitListingPage:(NSArray *)taxonomy customParameters:(NSArray *)customParameters) {
556
610
  @try {
557
- [Insider visitListingPageWithTaxonomy:taxonomy];
611
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:customParameters];
612
+
613
+ if (mappedCustomParameters.count > 0) {
614
+ [Insider visitListingPageWithTaxonomy:taxonomy customParameters:mappedCustomParameters];
615
+ } else {
616
+ [Insider visitListingPageWithTaxonomy:taxonomy];
617
+ }
558
618
  } @catch (NSException *e) {
559
619
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
560
620
  }
561
621
  }
562
622
 
563
- RCT_EXPORT_METHOD(visitProductDetailPage:(NSDictionary *)requiredFields optionalFields:(NSDictionary *)optionalFields customParameters:(NSArray *)customParameters) {
623
+ RCT_EXPORT_METHOD(visitProductDetailPage:(NSDictionary *)requiredFields optionalFields:(NSDictionary *)optionalFields customParameters:(NSArray *)customParameters eventCustomParameters:(NSArray *)eventCustomParameters) {
564
624
  @try {
565
625
  InsiderProduct *product = [RNUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
566
- [Insider visitProductDetailPageWithProduct:product];
626
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:eventCustomParameters];
627
+
628
+ if (mappedCustomParameters.count > 0) {
629
+ [Insider visitProductDetailPageWithProduct:product customParameters:mappedCustomParameters];
630
+ } else {
631
+ [Insider visitProductDetailPageWithProduct:product];
632
+ }
567
633
  } @catch (NSException *e) {
568
634
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
569
635
  }
570
636
  }
571
637
 
572
- RCT_EXPORT_METHOD(visitCartPage:(NSArray *)products) {
638
+ RCT_EXPORT_METHOD(visitCartPage:(NSArray *)products customParameters:(NSArray *)customParameters) {
573
639
  @try {
574
640
  NSMutableArray<InsiderProduct *> *mappedProducts = [NSMutableArray array];
575
641
  for (NSDictionary *productDict in products) {
576
642
  NSDictionary *requiredFields = productDict[@"requiredFields"];
577
643
  NSDictionary *optionalFields = productDict[@"optionalFields"];
578
- NSArray *customParameters = productDict[@"customParameters"];
579
- InsiderProduct *product = [RNUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
644
+ NSArray *productCustomParameters = productDict[@"customParameters"];
645
+ InsiderProduct *product = [RNUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:productCustomParameters];
580
646
  [mappedProducts addObject:product];
581
647
  }
582
- [Insider visitCartPageWithProducts:[mappedProducts copy]];
648
+
649
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:customParameters];
650
+
651
+ if (mappedCustomParameters.count > 0) {
652
+ [Insider visitCartPageWithProducts:[mappedProducts copy] customParameters:mappedCustomParameters];
653
+ } else {
654
+ [Insider visitCartPageWithProducts:[mappedProducts copy]];
655
+ }
583
656
  } @catch (NSException *e) {
584
657
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
585
658
  }
586
659
  }
587
660
 
588
- RCT_EXPORT_METHOD(visitWishlistPage:(NSArray *)products) {
661
+ RCT_EXPORT_METHOD(visitWishlistPage:(NSArray *)products customParameters:(NSArray *)customParameters) {
589
662
  @try {
590
663
  NSMutableArray<InsiderProduct *> *mappedProducts = [NSMutableArray array];
591
664
  for (NSDictionary *productDict in products) {
592
665
  NSDictionary *requiredFields = productDict[@"requiredFields"];
593
666
  NSDictionary *optionalFields = productDict[@"optionalFields"];
594
- NSArray *customParameters = productDict[@"customParameters"];
595
- InsiderProduct *product = [RNUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:customParameters];
667
+ NSArray *productCustomParameters = productDict[@"customParameters"];
668
+ InsiderProduct *product = [RNUtils parseProductFromRequiredFields:requiredFields andOptionalFields:optionalFields andCustomParameters:productCustomParameters];
596
669
  [mappedProducts addObject:product];
597
670
  }
598
- [Insider visitWishlistWithProducts:[mappedProducts copy]];
671
+
672
+ NSDictionary<NSString *, id> *mappedCustomParameters = [RNUtils parseCustomParameters:customParameters];
673
+
674
+ if (mappedCustomParameters.count > 0) {
675
+ [Insider visitWishlistWithProducts:[mappedProducts copy] customParameters:mappedCustomParameters];
676
+ } else {
677
+ [Insider visitWishlistWithProducts:[mappedProducts copy]];
678
+ }
599
679
  } @catch (NSException *e) {
600
680
  [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
601
681
  }
@@ -23,4 +23,6 @@
23
23
  andOptionalFields:(nullable NSDictionary *)optionalFields
24
24
  andCustomParameters:(nullable NSArray *)customParameters;
25
25
 
26
+ + (nonnull NSDictionary<NSString *, id> *)parseCustomParameters:(nonnull NSArray *)customParameters;
27
+
26
28
  @end
@@ -245,4 +245,42 @@
245
245
  return product;
246
246
  }
247
247
 
248
+ + (nonnull NSDictionary<NSString *, id> *)parseCustomParameters:(nonnull NSArray *)customParameters {
249
+ NSMutableDictionary<NSString *, id> *mappedCustomParameters = [NSMutableDictionary dictionary];
250
+
251
+ for (id item in customParameters) {
252
+ if (![item isKindOfClass:[NSDictionary class]]) continue;
253
+
254
+ NSDictionary *parameter = (NSDictionary *)item;
255
+ NSString *type = parameter[@"type"];
256
+ NSString *key = parameter[@"key"];
257
+
258
+ if (![type isKindOfClass:[NSString class]] || ![key isKindOfClass:[NSString class]]) continue;
259
+
260
+ id value = parameter[@"value"];
261
+
262
+ if ([type isEqualToString:@"string"] && [value isKindOfClass:[NSString class]]) {
263
+ NSString *stringValue = (NSString *)value;
264
+ mappedCustomParameters[key] = stringValue;
265
+ }
266
+ else if (([type isEqualToString:@"integer"] || [type isEqualToString:@"double"] || [type isEqualToString:@"boolean"]) && [value isKindOfClass:[NSNumber class]]) {
267
+ NSNumber *numberValue = (NSNumber *)value;
268
+ mappedCustomParameters[key] = numberValue;
269
+ }
270
+ else if ([type isEqualToString:@"date"] && [value isKindOfClass:[NSNumber class]]) {
271
+ NSNumber *numberValue = (NSNumber *)value;
272
+ long long epochMillis = numberValue.longLongValue;
273
+ NSTimeInterval seconds = ((NSTimeInterval)epochMillis) / 1000.0;
274
+ NSDate *dateValue = [NSDate dateWithTimeIntervalSince1970:seconds];
275
+ mappedCustomParameters[key] = dateValue;
276
+ }
277
+ else if (([type isEqualToString:@"numeric_array"] || [type isEqualToString:@"string_array"]) && [value isKindOfClass:[NSArray class]]) {
278
+ NSArray *arrayValue = (NSArray *)value;
279
+ mappedCustomParameters[key] = arrayValue;
280
+ }
281
+ }
282
+
283
+ return mappedCustomParameters;
284
+ }
285
+
248
286
  @end
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "react-native-insider",
3
- "version": "7.0.11",
3
+ "version": "7.0.12",
4
4
  "description": "React Native Insider SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
+ "scripts": {
8
+ "test": "jest"
9
+ },
7
10
  "keywords": [
8
11
  "react-native",
9
12
  "ios",
@@ -15,5 +18,21 @@
15
18
  "insider"
16
19
  ],
17
20
  "author": "insidermobile",
18
- "homepage": "https://github.com/useinsider/react-native-insider"
19
- }
21
+ "homepage": "https://github.com/useinsider/react-native-insider",
22
+ "devDependencies": {
23
+ "@babel/core": "^7.20.0",
24
+ "@babel/preset-env": "^7.20.0",
25
+ "@react-native/babel-preset": "0.83.0",
26
+ "babel-jest": "^30.2.0",
27
+ "jest": "^29.7.0",
28
+ "react": "19.2.0",
29
+ "react-native": "0.83.0"
30
+ },
31
+ "jest": {
32
+ "preset": "react-native",
33
+ "modulePathIgnorePatterns": [
34
+ "<rootDir>/example/node_modules",
35
+ "<rootDir>/lib/"
36
+ ]
37
+ }
38
+ }
@@ -0,0 +1,6 @@
1
+ const CloseButtonPosition = {
2
+ LEFT: "LEFT",
3
+ RIGHT: "RIGHT",
4
+ NONE: "NONE"
5
+ };
6
+ export default CloseButtonPosition;
package/src/Util.js CHANGED
@@ -33,3 +33,64 @@ export function showParameterWarningLog(functionName, parameters = []) {
33
33
  `Invalid Parameters:\n${invalidParams.join("\n")}`
34
34
  );
35
35
  }
36
+
37
+ export function isPlainObject(value) {
38
+ if (value === null || typeof value !== 'object') {
39
+ return false;
40
+ }
41
+
42
+ return Object.getPrototypeOf(value) === Object.prototype ||
43
+ Object.getPrototypeOf(value) === null;
44
+ }
45
+
46
+ export function detectType(value) {
47
+ if (typeof value === 'boolean') {
48
+ return 'boolean';
49
+ }
50
+
51
+ if (value instanceof Date) {
52
+ return 'date';
53
+ }
54
+
55
+ if (Array.isArray(value)) {
56
+ if (value.every(item => typeof item === 'number')) {
57
+ return 'numeric_array';
58
+ }
59
+
60
+ if (value.every(item => typeof item === 'string')) {
61
+ return 'string_array';
62
+ }
63
+
64
+ return 'unknown';
65
+ }
66
+
67
+ if (typeof value === 'number' && !isNaN(value)) {
68
+ if (Number.isInteger(value)) {
69
+ return 'integer';
70
+ }
71
+
72
+ return 'double';
73
+ }
74
+
75
+ if (typeof value === 'string') {
76
+ return 'string';
77
+ }
78
+
79
+ return 'unknown';
80
+ }
81
+
82
+ export function parseObjectWithTypes(parameters) {
83
+ if (!isPlainObject(parameters)) {
84
+ return [];
85
+ }
86
+
87
+ return Object.entries(parameters).map(([key, value]) => {
88
+ const type = detectType(value);
89
+
90
+ return {
91
+ key: key,
92
+ type: type,
93
+ value: type === 'date' ? value.getTime() : value
94
+ };
95
+ }).filter(param => param.type !== 'unknown');
96
+ }