cordova-plugin-insider 2.1.1 → 2.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-insider",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "A plugin that you can use Insider SDK with Cordova and Ionic",
5
5
  "cordova_name": "Insider Cordova Plugin",
6
6
  "cordova": {
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cordova-plugin-insider" version="2.1.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <plugin id="cordova-plugin-insider" version="2.2.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
3
3
  <name>Insider</name>
4
4
  <description>Insider Cordova Plugin</description>
5
5
  <keywords>insider,cordova,cordova-ios,cordova-android</keywords>
@@ -70,9 +70,9 @@
70
70
  <source url="https://cdn.cocoapods.org/" />
71
71
  </config>
72
72
  <pods use-frameworks="true">
73
- <pod name="InsiderMobile" spec="13.4.3" />
74
- <pod name="InsiderGeofence" spec="1.1.3" />
75
- <pod name="InsiderHybrid" spec="1.4.0" />
73
+ <pod name="InsiderMobile" spec="13.8.1" />
74
+ <pod name="InsiderGeofence" spec="1.2.0" />
75
+ <pod name="InsiderHybrid" spec="1.6.1" />
76
76
  </pods>
77
77
  </podspec>
78
78
 
@@ -684,6 +684,90 @@ public class InsiderPlugin extends CordovaPlugin {
684
684
 
685
685
  Insider.Instance.registerInsiderIDListener(insiderIDListener);
686
686
  }
687
+ } else if (action.equals("disableInAppMessages")) {
688
+ cordova.getActivity().runOnUiThread(new Runnable() {
689
+ @Override
690
+ public void run() {
691
+ try {
692
+ Insider.Instance.disableInAppMessages();
693
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
694
+ } catch (Exception e) {
695
+ Insider.Instance.putException(e);
696
+ }
697
+ }
698
+ });
699
+ } else if (action.equals("enableInAppMessages")) {
700
+ cordova.getActivity().runOnUiThread(new Runnable() {
701
+ @Override
702
+ public void run() {
703
+ try {
704
+ Insider.Instance.enableInAppMessages();
705
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
706
+ } catch (Exception e) {
707
+ Insider.Instance.putException(e);
708
+ }
709
+ }
710
+ });
711
+ } else if (action.equals("itemAddedToWishlist")) {
712
+ if (args.get(0) == null || args.getString(1) == null)
713
+ return false;
714
+
715
+ Map<String, Object> mustMap = CDVUtils.convertJSONToMap(args.getString(0));
716
+ Map<String, Object> optMap = CDVUtils.convertJSONToMap(args.getString(1));
717
+
718
+ cordova.getThreadPool().execute(new Runnable() {
719
+ @Override
720
+ public void run() {
721
+ InsiderProduct product = createProduct(mustMap, optMap);
722
+ Insider.Instance.itemAddedToWishlist(product);
723
+ callbackSuccess(callbackContext, "SUCCESS");
724
+ }
725
+ });
726
+ } else if (action.equals("itemRemovedFromWishlist")) {
727
+ if (args.get(0) == null)
728
+ return false;
729
+
730
+ cordova.getThreadPool().execute(new Runnable() {
731
+ @Override
732
+ public void run() {
733
+ try {
734
+ Insider.Instance.itemRemovedFromWishlist(args.getString(0));
735
+ callbackSuccess(callbackContext, "SUCCESS");
736
+ } catch (JSONException e) {
737
+ e.printStackTrace();
738
+ }
739
+ }
740
+ });
741
+ } else if (action.equals("wishlistCleared")) {
742
+ cordova.getThreadPool().execute(new Runnable() {
743
+ @Override
744
+ public void run() {
745
+ Insider.Instance.wishlistCleared();
746
+ callbackSuccess(callbackContext, "SUCCESS");
747
+ }
748
+ });
749
+ } else if (action.equals("visitWishlistPage")) {
750
+ if (args.get(0) == null)
751
+ return false;
752
+
753
+ String json = args.getString(0);
754
+ ArrayList products = new ObjectMapper().readValue(json, ArrayList.class);
755
+ InsiderProduct[] ips = new InsiderProduct[products.size()];
756
+
757
+ cordova.getThreadPool().execute(new Runnable() {
758
+ @Override
759
+ public void run() {
760
+ for (int i = 0; i < products.size(); i++) {
761
+ HashMap mustMap = (HashMap)(((LinkedHashMap)products.get(i)).get("productMustMap"));
762
+ HashMap optMap = (HashMap)(((LinkedHashMap)products.get(i)).get("productOptMap"));
763
+ InsiderProduct product = createProduct(mustMap, optMap);
764
+ ips[i] = product;
765
+ }
766
+
767
+ Insider.Instance.visitWishlistPage(ips);
768
+ callbackSuccess(callbackContext, "SUCCESS");
769
+ }
770
+ });
687
771
  } else {
688
772
  return false;
689
773
  }
@@ -5,32 +5,32 @@ repositories {
5
5
  }
6
6
 
7
7
  android {
8
- compileSdkVersion 31
8
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
9
9
  useLibrary 'org.apache.http.legacy'
10
10
 
11
11
  defaultConfig {
12
- minSdkVersion 21
13
- targetSdkVersion 31
12
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
13
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
14
14
  multiDexEnabled true
15
15
  }
16
16
  }
17
17
 
18
18
  dependencies {
19
- implementation 'com.useinsider:insider:14.2.4'
20
- implementation 'com.useinsider:insiderhybrid:1.1.6'
19
+ implementation 'com.useinsider:insider:14.6.0'
20
+ implementation 'com.useinsider:insiderhybrid:1.2.0'
21
21
 
22
22
  implementation 'com.fasterxml.jackson.core:jackson-core:2.12.4'
23
23
  implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.4'
24
24
 
25
25
  implementation 'androidx.legacy:legacy-support-v4:1.0.0'
26
- implementation 'androidx.lifecycle:lifecycle-process:2.3.1'
26
+ implementation 'androidx.lifecycle:lifecycle-process:2.7.0'
27
27
  implementation 'androidx.security:security-crypto:1.1.0-alpha06'
28
28
 
29
- implementation 'com.google.android.gms:play-services-location:21.0.1'
30
- implementation 'com.google.firebase:firebase-messaging:23.0.5'
29
+ implementation 'com.google.android.gms:play-services-location:21.3.0'
30
+ implementation 'com.google.firebase:firebase-messaging:24.0.0'
31
31
  implementation 'com.google.android.play:review:2.0.1'
32
32
 
33
- implementation 'com.huawei.hms:push:6.5.0.300'
34
- implementation 'com.huawei.hms:ads-identifier:3.4.39.302'
35
- implementation 'com.huawei.hms:location:6.4.0.300'
33
+ implementation 'com.huawei.hms:push:6.12.0.300'
34
+ implementation 'com.huawei.hms:ads-identifier:3.4.62.300'
35
+ implementation 'com.huawei.hms:location:6.11.0.301'
36
36
  }
@@ -62,4 +62,10 @@
62
62
  - (void) handleNotification:(CDVInvokedUrlCommand *)command;
63
63
  - (void) getInsiderID:(CDVInvokedUrlCommand *)command;
64
64
  - (void) registerInsiderIDListener:(CDVInvokedUrlCommand *)command;
65
+ - (void) disableInAppMessages:(CDVInvokedUrlCommand *)command;
66
+ - (void) enableInAppMessages:(CDVInvokedUrlCommand *)command;
67
+ - (void) itemAddedToWishlist:(CDVInvokedUrlCommand *)command;
68
+ - (void) itemRemovedFromWishlist:(CDVInvokedUrlCommand *)command;
69
+ - (void) wishlistCleared:(CDVInvokedUrlCommand *)command;
70
+ - (void) visitWishlistPage:(CDVInvokedUrlCommand *)command;
65
71
  @end
@@ -800,6 +800,83 @@
800
800
  }
801
801
  }
802
802
 
803
+ - (void)disableInAppMessages:(CDVInvokedUrlCommand *)command {
804
+ @try {
805
+ dispatch_async(dispatch_get_main_queue(), ^{
806
+ [Insider disableInAppMessages];
807
+
808
+ [self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
809
+ });
810
+ } @catch (NSException *exception) {
811
+ [Insider sendError:exception desc:@"Insider.m - tagEvent"];
812
+ }
813
+ }
814
+
815
+ - (void)enableInAppMessages:(CDVInvokedUrlCommand *)command {
816
+ @try {
817
+ dispatch_async(dispatch_get_main_queue(), ^{
818
+ [Insider enableInAppMessages];
819
+
820
+ [self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
821
+ });
822
+ } @catch (NSException *exception) {
823
+ [Insider sendError:exception desc:@"Insider.m - tagEvent"];
824
+ }
825
+ }
826
+
827
+ - (void)itemAddedToWishlist:(CDVInvokedUrlCommand *)command {
828
+ @try {
829
+ [self.commandDelegate runInBackground:^{
830
+ if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
831
+
832
+ InsiderProduct *product = (InsiderProduct *)[InsiderHybrid createProduct:[command.arguments objectAtIndex:0] productOptMap:[command.arguments objectAtIndex:1]];
833
+
834
+ [Insider itemAddedToWishlistWithProduct:product];
835
+
836
+ [self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
837
+ }];
838
+ } @catch (NSException *e) {
839
+ [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
840
+ }
841
+ }
842
+
843
+ - (void)itemRemovedFromWishlist:(CDVInvokedUrlCommand *)command {
844
+ @try {
845
+ [self.commandDelegate runInBackground:^{
846
+ if (![command.arguments objectAtIndex:0]) return;
847
+
848
+ [Insider itemRemovedFromWishlistWithProductID:[command.arguments objectAtIndex:0]];
849
+ [self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
850
+ }];
851
+ } @catch (NSException *e) {
852
+ [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
853
+ }
854
+ }
855
+
856
+ - (void)wishlistCleared:(CDVInvokedUrlCommand *)command {
857
+ @try {
858
+ [self.commandDelegate runInBackground:^{
859
+ [Insider wishlistCleared];
860
+
861
+ [self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
862
+ }];
863
+ } @catch (NSException *e) {
864
+ [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
865
+ }
866
+ }
867
+
868
+ - (void)visitWishlistPage:(CDVInvokedUrlCommand *)command {
869
+ @try {
870
+ [self.commandDelegate runInBackground:^{
871
+ if (![command.arguments objectAtIndex:0]) return;
872
+ [Insider visitWishlistWithProducts:[InsiderHybrid convertArrayToInsiderProductArray:[command.arguments objectAtIndex:0]]];
873
+ [self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
874
+ }];
875
+ } @catch (NSException *e) {
876
+ [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
877
+ }
878
+ }
879
+
803
880
  - (void)putException:(CDVInvokedUrlCommand *)command {
804
881
  @try {
805
882
  if (![command.arguments objectAtIndex:0]) return;
package/www/Constants.js CHANGED
@@ -66,6 +66,12 @@ module.exports = {
66
66
  HANDLE_NOTIFICATION: 'handleNotification',
67
67
  GET_INSIDER_ID: 'getInsiderID',
68
68
  REGISTER_INSIDER_ID_LISTENER: 'registerInsiderIDListener',
69
+ DISABLE_IN_APP_MESSAGES: 'disableInAppMessages',
70
+ ENABLE_IN_APP_MESSAGES: 'enableInAppMessages',
71
+ ITEM_ADDED_TO_WISHLIST: 'itemAddedToWishlist',
72
+ ITEM_REMOVED_FROM_WISHLIST: 'itemRemovedFromWishlist',
73
+ WISHLIST_CLEARED: 'wishlistCleared',
74
+ VISIT_WISHLIST_PAGE: 'visitWishlistPage',
69
75
  // Event
70
76
  TAG_EVENT: 'tagEvent',
71
77
  // Product Attribute
@@ -88,5 +94,5 @@ module.exports = {
88
94
  // Reinit
89
95
  REINIT_WITH_PARTNER_NAME: 'reinitWithPartnerName',
90
96
  // SDK Version
91
- SDK_VERSION: 'CDV-2.1.1',
97
+ SDK_VERSION: 'CDV-2.2.0',
92
98
  };
@@ -543,6 +543,79 @@ class InsiderPlugin {
543
543
  Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
544
544
  }
545
545
  }
546
+
547
+ disableInAppMessages = () => {
548
+ try {
549
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.DISABLE_IN_APP_MESSAGES, []);
550
+ } catch (error) {
551
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
552
+ }
553
+ }
554
+
555
+ enableInAppMessages = () => {
556
+ try {
557
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ENABLE_IN_APP_MESSAGES, []);
558
+ } catch (error) {
559
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
560
+ }
561
+ }
562
+
563
+ itemAddedToWishlist = (product) => {
564
+ if (Utils.checkParameters([{ type: 'object', value: product }])) {
565
+ Utils.showParameterWarningLog(this.constructor.name + '-itemAddedToWishlist');
566
+ return;
567
+ }
568
+
569
+ try {
570
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ITEM_ADDED_TO_WISHLIST, [product.productMustMap, product.productOptMap]);
571
+ } catch (error) {
572
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
573
+ }
574
+ }
575
+
576
+ itemRemovedFromWishlist = (productID) => {
577
+ if (Utils.checkParameters([{ type: 'string', value: productID }])) {
578
+ Utils.showParameterWarningLog(this.constructor.name + '-itemRemovedFromWishlist');
579
+ return;
580
+ }
581
+
582
+ try {
583
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.ITEM_REMOVED_FROM_WISHLIST, [productID]);
584
+ } catch (error) {
585
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
586
+ }
587
+ }
588
+
589
+ wishlistCleared = () => {
590
+ try {
591
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.WISHLIST_CLEARED, []);
592
+ } catch (error) {
593
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
594
+ }
595
+ }
596
+
597
+ visitWishlistPage = (products) => {
598
+ if (Utils.checkParameters([{ type: 'object', value: products }])) {
599
+ Utils.showParameterWarningLog(this.constructor.name + '-visitWishlistPage');
600
+ return;
601
+ }
602
+
603
+ try {
604
+ let productMap = {};
605
+ let mappedProducts = new Array(products.length);
606
+
607
+ products.forEach((product, i) => {
608
+ productMap['productMustMap'] = product.productMustMap;
609
+ productMap['productOptMap'] = product.productOptMap;
610
+
611
+ mappedProducts[i] = productMap;
612
+ });
613
+
614
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.VISIT_WISHLIST_PAGE, [mappedProducts]);
615
+ } catch (error) {
616
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
617
+ }
618
+ }
546
619
  }
547
620
 
548
621
  module.exports = new InsiderPlugin();