cordova-plugin-insider 1.3.0 → 1.5.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": "1.3.0",
3
+ "version": "1.5.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="1.3.0" 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="1.5.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>
@@ -28,9 +28,8 @@
28
28
  <platform name="android">
29
29
  <framework src="src/android/build-extras.gradle" custom="true" type="gradleReference" />
30
30
 
31
- <hook type="before_plugin_uninstall" src="hooks/before_plugin_uninstall.js"/>
32
- <hook type="after_plugin_install" src="hooks/after_plugin_install.js"/>
33
-
31
+ <hook type="before_plugin_uninstall" src="hooks/before_plugin_uninstall.js"/>
32
+ <hook type="after_plugin_install" src="hooks/after_plugin_install.js"/>
34
33
 
35
34
  <config-file target="config.xml" parent="/*">
36
35
  <preference name="GradlePluginGoogleServicesEnabled" value="true" />
@@ -71,8 +70,9 @@
71
70
  <source url="https://cdn.cocoapods.org/" />
72
71
  </config>
73
72
  <pods use-frameworks="true">
74
- <pod name="InsiderMobile" spec="12.5.2" />
75
- <pod name="InsiderHybrid" spec="1.2.1" />
73
+ <pod name="InsiderMobile" spec="12.8.6" />
74
+ <pod name="InsiderGeofence" spec="1.0.3" />
75
+ <pod name="InsiderHybrid" spec="1.4.0" />
76
76
  </pods>
77
77
  </podspec>
78
78
 
@@ -38,4 +38,5 @@ class Constants {
38
38
  static final String VOUCHER_DISCOUNT = "voucher_discount";
39
39
  static final String PROMOTION_NAME = "promotion_name";
40
40
  static final String PROMOTION_DISCOUNT = "promotion_discount";
41
+ static final String GROUP_CODE = "groupcode";
41
42
  }
@@ -87,7 +87,6 @@ public class InsiderPlugin extends CordovaPlugin {
87
87
  }
88
88
  });
89
89
 
90
- Insider.Instance.handleHybridIntent();
91
90
  Insider.Instance.storePartnerName(partnerName);
92
91
  }
93
92
  });
@@ -115,8 +114,6 @@ public class InsiderPlugin extends CordovaPlugin {
115
114
  init(args.getString(0), args.getString(1));
116
115
  } else if (action.equals("setGDPRConsent")) {
117
116
  Insider.Instance.setGDPRConsent(Boolean.parseBoolean(args.getString(0)));
118
- } else if (action.equals("enableIDFACollection")) {
119
- Insider.Instance.enableIDFACollection(Boolean.parseBoolean(args.getString(0)));
120
117
  } else if (action.equals("startTrackingGeofence")) {
121
118
  cordova.getThreadPool().execute(new Runnable() {
122
119
  @Override
@@ -273,6 +270,32 @@ public class InsiderPlugin extends CordovaPlugin {
273
270
  }
274
271
  }
275
272
  });
273
+ } else if (action.equals("getSmartRecommendationWithProductIDs")) {
274
+ if (args.get(0) == null || args.get(1) == null || args.get(2) == null || args.get(3) == null)
275
+ return false;
276
+
277
+ cordova.getThreadPool().execute(new Runnable() {
278
+ @Override
279
+ public void run() {
280
+ try {
281
+ String[] productIDs = (CDVUtils.convertJSONToArrayList(args.get(0).toString())).toArray(new String[0]);
282
+
283
+ Insider.Instance.getSmartRecommendationWithProductIDs(productIDs,
284
+ args.getInt(1),
285
+ args.getString(2),
286
+ args.getString(3),
287
+ new RecommendationEngine.SmartRecommendation() {
288
+ @Override
289
+ public void loadRecommendationData(JSONObject jsonObject) {
290
+ callbackSuccess(callbackContext, jsonObject.toString());
291
+ }
292
+ });
293
+ } catch (JSONException e) {
294
+ callbackFailure(callbackContext, "ERROR:" + e.toString());
295
+ e.printStackTrace();
296
+ }
297
+ }
298
+ });
276
299
  } else if (action.equals(InsiderHybridMethods.CLICK_SMART_RECOMMENDATION_PRODUCT)) {
277
300
  if (args.get(0) == null || args.get(1) == null || args.get(2) == null)
278
301
  return false;
@@ -770,6 +793,9 @@ public class InsiderPlugin extends CordovaPlugin {
770
793
  case Constants.PROMOTION_DISCOUNT:
771
794
  product.setPromotionDiscount((double) value);
772
795
  break;
796
+ case Constants.GROUP_CODE:
797
+ product.setGroupCode((String) value);
798
+ break;
773
799
  default:
774
800
  setProductCustomAttribute(product, entry.getKey(), value);
775
801
  break;
@@ -11,16 +11,13 @@ android {
11
11
  defaultConfig {
12
12
  minSdkVersion 21
13
13
  targetSdkVersion 31
14
- versionCode 1
15
- versionName "1.0"
16
- manifestPlaceholders = [ partner: "partner_name" ]
17
14
  multiDexEnabled true
18
15
  }
19
16
  }
20
17
 
21
18
  dependencies {
22
- implementation 'com.useinsider:insider:13.4.2'
23
- implementation 'com.useinsider:insiderhybrid:1.1.4'
19
+ implementation 'com.useinsider:insider:13.8.5'
20
+ implementation 'com.useinsider:insiderhybrid:1.1.6'
24
21
 
25
22
  implementation 'com.fasterxml.jackson.core:jackson-core:2.12.4'
26
23
  implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.4'
@@ -30,9 +27,11 @@ dependencies {
30
27
 
31
28
  implementation 'com.google.android.gms:play-services-location:20.0.0'
32
29
  implementation 'com.google.firebase:firebase-messaging:23.0.5'
33
- implementation 'com.google.android.gms:play-services-ads:16.0.0'
30
+ implementation 'com.google.android.play:core-ktx:1.8.1'
34
31
 
35
32
  implementation 'com.huawei.hms:push:6.5.0.300'
36
33
  implementation 'com.huawei.hms:ads-identifier:3.4.39.302'
37
34
  implementation 'com.huawei.hms:location:6.4.0.300'
35
+
36
+ implementation 'androidx.security:security-crypto:1.0.0'
38
37
  }
@@ -1,6 +1,7 @@
1
1
  #import <InsiderMobile/Insider.h>
2
2
  #import <InsiderHybrid/InsiderHybrid.h>
3
3
  #import <InsiderMobile/InsiderCallbackTypeEnum.h>
4
+ #import <InsiderGeofence/InsiderGeofence.h>
4
5
  #import "IDFAHelper.h"
5
6
  #import <UserNotifications/UserNotifications.h>
6
7
 
@@ -30,6 +31,7 @@
30
31
  - (void) cartCleared:(CDVInvokedUrlCommand *)command;
31
32
  - (void) getSmartRecommendation:(CDVInvokedUrlCommand *)command;
32
33
  - (void) getSmartRecommendationWithProduct:(CDVInvokedUrlCommand *)command;
34
+ - (void) getSmartRecommendationWithProductIDs:(CDVInvokedUrlCommand *)command;
33
35
  - (void) clickSmartRecommendationProduct:(CDVInvokedUrlCommand *)command;
34
36
  - (void) getMessageCenterData:(CDVInvokedUrlCommand *)command;
35
37
  - (void) setGender:(CDVInvokedUrlCommand *)command;
@@ -62,41 +62,47 @@
62
62
  }
63
63
  }
64
64
 
65
- -(void)registerCallback:(NSDictionary *)notfDict {
65
+ -(void)registerCallback:(NSDictionary *)callbackDictionary {
66
66
  @try {
67
- if (!notfDict || [notfDict count] == 0)
67
+ if (!callbackDictionary || [callbackDictionary count] == 0)
68
68
  return;
69
- InsiderCallbackType type = (InsiderCallbackType)[[notfDict objectForKey:@"type"] intValue];
70
- NSString* notfData = [InsiderHybrid dictToJson:notfDict];
69
+ InsiderCallbackType type = (InsiderCallbackType)[[callbackDictionary objectForKey:@"type"] intValue];
70
+ NSString* callbackData = [InsiderHybrid dictToJson:callbackDictionary];
71
71
 
72
72
  NSString *js;
73
73
  switch (type) {
74
74
  case InsiderCallbackTypeNotificationOpen:{
75
- NSString * data = [NSString stringWithFormat:@"{""action"":'NOTIFICATION_OPEN',""result"":""%@""}", notfData];
75
+ NSString * data = [NSString stringWithFormat:@"{""action"":'NOTIFICATION_OPEN',""result"":""%@""}", callbackData];
76
76
  js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
77
77
  [self.commandDelegate evalJs:js];
78
78
  break;
79
79
  }
80
80
  case InsiderCallbackTypeInappButtonClick:{
81
- NSString * data = [NSString stringWithFormat:@"{""action"":'INAPP_BUTTON_CLICK',""result"":""%@""}", notfData];
81
+ NSString * data = [NSString stringWithFormat:@"{""action"":'INAPP_BUTTON_CLICK',""result"":""%@""}", callbackData];
82
82
  js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
83
83
  [self.commandDelegate evalJs:js];
84
84
  break;
85
85
  }
86
86
  case InsiderCallbackTypeTempStorePurchase:{
87
- NSString * data = [NSString stringWithFormat:@"{""action"":'TEMP_STORE_PURCHASE',""result"":""%@""}", notfData];
87
+ NSString * data = [NSString stringWithFormat:@"{""action"":'TEMP_STORE_PURCHASE',""result"":""%@""}", callbackData];
88
88
  js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
89
89
  [self.commandDelegate evalJs:js];
90
90
  break;
91
91
  }
92
92
  case InsiderCallbackTypeTempStoreAddedToCart:{
93
- NSString * data = [NSString stringWithFormat:@"{""action"":'TEMP_STORE_ADDED_TO_CART',""result"":""%@""}", notfData];
93
+ NSString * data = [NSString stringWithFormat:@"{""action"":'TEMP_STORE_ADDED_TO_CART',""result"":""%@""}", callbackData];
94
94
  js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
95
95
  [self.commandDelegate evalJs:js];
96
96
  break;
97
97
  }
98
98
  case InsiderCallbackTypeTempStoreCustomAction:{
99
- NSString * data = [NSString stringWithFormat:@"{""action"":'TEMP_STORE_CUSTOM_ACTION',""result"":""%@""}", notfData];
99
+ NSString * data = [NSString stringWithFormat:@"{""action"":'TEMP_STORE_CUSTOM_ACTION',""result"":""%@""}", callbackData];
100
+ js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
101
+ [self.commandDelegate evalJs:js];
102
+ break;
103
+ }
104
+ case InsiderCallbackTypeInAppSeen:{
105
+ NSString * data = [NSString stringWithFormat:@"{""action"":'INAPP_SEEN',""result"":""%@""}", callbackData];
100
106
  js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
101
107
  [self.commandDelegate evalJs:js];
102
108
  break;
@@ -138,7 +144,7 @@
138
144
  - (void) startTrackingGeofence:(CDVInvokedUrlCommand *)command {
139
145
  @try {
140
146
  [self.commandDelegate runInBackground:^{
141
- [Insider startTrackingGeofence];
147
+ [InsiderGeofence startTracking];
142
148
  [self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
143
149
  }];
144
150
  } @catch (NSException *exception) {
@@ -390,6 +396,20 @@
390
396
  }
391
397
  }
392
398
 
399
+ - (void)getSmartRecommendationWithProductIDs:(CDVInvokedUrlCommand *)command {
400
+ @try {
401
+ [self.commandDelegate runInBackground:^{
402
+ if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2] || ![command.arguments objectAtIndex:3]) return;
403
+
404
+ [Insider getSmartRecommendationWithProductIDs:[command.arguments objectAtIndex:0] recommendationID:[[command.arguments objectAtIndex:1] intValue] locale:[command.arguments objectAtIndex:2] currency:[command.arguments objectAtIndex:3] smartRecommendation:^(NSDictionary *recommendation) {
405
+ [self sendSuccessResultWithDictionary:recommendation andCommand:command];
406
+ }];
407
+ }];
408
+ } @catch (NSException *e) {
409
+ [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
410
+ }
411
+ }
412
+
393
413
  - (void)clickSmartRecommendationProduct:(CDVInvokedUrlCommand *)command {
394
414
  @try {
395
415
  dispatch_async(dispatch_get_main_queue(), ^{
@@ -19,6 +19,7 @@ interface InsiderPlugin {
19
19
  getMessageCenterData(limit: number, startDate: Date, endDate: Date): Promise <any>;
20
20
  getSmartRecommendation(recommendationID: number, locale: string, currency: string): Promise <any>;
21
21
  getSmartRecommendationWithProduct(product: object, recommendationID: number, locale: string): Promise <any>;
22
+ getSmartRecommendationWithProductIDs(product: Array<string>, recommendationID: number, locale: string): Promise <any>;
22
23
  clickSmartRecommendationProduct(product: object, recommendationID: number);
23
24
  getContentStringWithName(variableName: string, defaultValue: any, contentOptimizerDataType: number): Promise <any>;
24
25
  getContentBoolWithName(variableName: string, defaultValue: boolean, contentOptimizerDataType: number): Promise <any>;
@@ -9,6 +9,7 @@ export interface Product {
9
9
  setPromotionDiscount(promotionDiscount: number):Product;
10
10
  setStock(setStock: number):Product;
11
11
  setQuantity(quantity: number):Product;
12
+ setGroupCode(groupCode: string):Product;
12
13
  setCustomAttributeWithString(key: string, value: string):Product;
13
14
  setCustomAttributeWithInt(key: string, value: number):Product;
14
15
  setCustomAttributeWithBoolean(key: string, value: boolean):Product;
@@ -4,4 +4,5 @@ module.exports = {
4
4
  TEMP_STORE_PURCHASE: 2,
5
5
  TEMP_STORE_ADDED_TO_CART: 3,
6
6
  TEMP_STORE_CUSTOM_ACTION: 4,
7
+ INAPP_SEEN: 5,
7
8
  };
package/www/Constants.js CHANGED
@@ -42,6 +42,7 @@ module.exports = {
42
42
  GET_MESSAGE_CENTER_DATA: 'getMessageCenterData',
43
43
  GET_SMART_RECOMMENDATION: 'getSmartRecommendation',
44
44
  GET_SMART_RECOMMENDATION_WITH_PRODUCT: 'getSmartRecommendationWithProduct',
45
+ GET_SMART_RECOMMENDATION_WITH_PRODUCT_IDS: 'getSmartRecommendationWithProductIDs',
45
46
  CLICK_SMART_RECOMMENDATION_PRODUCT: 'clickSmartRecommendationProduct',
46
47
  GET_CONTENT_STRING_WITH_NAME: 'getContentStringWithName',
47
48
  GET_CONTENT_BOOL_WITH_NAME: 'getContentBoolWithName',
@@ -76,11 +77,12 @@ module.exports = {
76
77
  VOUCHER_DISCOUNT: 'voucher_discount',
77
78
  PROMOTION_NAME: 'promotion_name',
78
79
  PROMOTION_DISCOUNT: 'promotion_discount',
80
+ GROUP_CODE: 'groupcode',
79
81
  // Error
80
82
  PUT_ERROR_LOG: 'putErrorLog',
81
83
  // Platform
82
84
  ANDROID: 'android',
83
85
  IOS: 'ios',
84
86
  // SDK Version
85
- SDK_VERSION: 'CDV-1.3.0',
87
+ SDK_VERSION: 'CDV-1.5.0',
86
88
  };
package/www/Event.js CHANGED
@@ -12,7 +12,10 @@ class Event {
12
12
  }
13
13
 
14
14
  addParameterWithString(key, value) {
15
- if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithString key or value'); return this;}
15
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'string', value: value }])) {
16
+ Utils.showParameterWarningLog(this.constructor.name + '-addParameterWithString');
17
+ return this;
18
+ }
16
19
 
17
20
  try {
18
21
  this.parameters[key] = value;
@@ -24,7 +27,10 @@ class Event {
24
27
  }
25
28
 
26
29
  addParameterWithInt(key, value) {
27
- if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithInt key or value'); return this;}
30
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'number', value: value }])) {
31
+ Utils.showParameterWarningLog(this.constructor.name + '-addParameterWithInt');
32
+ return this;
33
+ }
28
34
 
29
35
  try {
30
36
  this.parameters[key] = value;
@@ -36,7 +42,10 @@ class Event {
36
42
  }
37
43
 
38
44
  addParameterWithDouble(key, value) {
39
- if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithDouble key or value'); return this;}
45
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'number', value: value }])) {
46
+ Utils.showParameterWarningLog(this.constructor.name + '-addParameterWithDouble');
47
+ return this;
48
+ }
40
49
 
41
50
  try {
42
51
  this.parameters[key] = value;
@@ -48,7 +57,10 @@ class Event {
48
57
  }
49
58
 
50
59
  addParameterWithBoolean(key, value) {
51
- if (key === null || value === null || Utils.isEmpty(key)|| Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithBoolean key or value'); return this;}
60
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'boolean', value: value }])) {
61
+ Utils.showParameterWarningLog(this.constructor.name + '-addParameterWithBoolean');
62
+ return this;
63
+ }
52
64
 
53
65
  try {
54
66
  this.parameters[key] = value;
@@ -60,10 +72,12 @@ class Event {
60
72
  }
61
73
 
62
74
  addParameterWithDate(key, value) {
63
- if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithDate key or value'); return this;}
75
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'object', value: value }])) {
76
+ Utils.showParameterWarningLog(this.constructor.name + '-addParameterWithDate');
77
+ return this;
78
+ }
64
79
 
65
80
  try {
66
-
67
81
  this.parameters[key] = value.toISOString();
68
82
 
69
83
  return this;
@@ -73,7 +87,10 @@ class Event {
73
87
  }
74
88
 
75
89
  addParameterWithArray(key, value) {
76
- if (key === null || value === null || Utils.isEmpty(key) || Utils.isEmpty(value)){ Utils.showWarning(this.constructor.name + '-addParameterWithArray key or value'); return this;}
90
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'object', value: value }])) {
91
+ Utils.showParameterWarningLog(this.constructor.name + '-addParameterWithArray');
92
+ return this;
93
+ }
77
94
 
78
95
  try {
79
96
  this.parameters[key] = value;
package/www/Identifier.js CHANGED
@@ -11,7 +11,10 @@ class Identifier {
11
11
  }
12
12
 
13
13
  addEmail(email) {
14
- if (email === null || Utils.isEmpty(email)){ Utils.showWarning(this.constructor.name + '-email'); return this;}
14
+ if (Utils.checkParameters([{ type: 'string', value: email }])) {
15
+ Utils.showParameterWarningLog(this.constructor.name + '-addEmail');
16
+ return this;
17
+ }
15
18
 
16
19
  try {
17
20
  this.identifiers[InsiderConstants.ADD_EMAIL] = email;
@@ -23,7 +26,10 @@ class Identifier {
23
26
  }
24
27
 
25
28
  addPhoneNumber(phoneNumber) {
26
- if (phoneNumber === null || Utils.isEmpty(phoneNumber)){ Utils.showWarning(this.constructor.name + '-phoneNumber'); return this;}
29
+ if (Utils.checkParameters([{ type: 'string', value: phoneNumber }])) {
30
+ Utils.showParameterWarningLog(this.constructor.name + '-addPhoneNumber');
31
+ return this;
32
+ }
27
33
 
28
34
  try {
29
35
  this.identifiers[InsiderConstants.ADD_PHONE_NUMBER] = phoneNumber;
@@ -35,7 +41,10 @@ class Identifier {
35
41
  }
36
42
 
37
43
  addUserID(userID) {
38
- if (userID === null || Utils.isEmpty(userID)){ Utils.showWarning(this.constructor.name + '-userID'); return this;}
44
+ if (Utils.checkParameters([{ type: 'string', value: userID }])) {
45
+ Utils.showParameterWarningLog(this.constructor.name + '-addUserID');
46
+ return this;
47
+ }
39
48
 
40
49
  try {
41
50
  this.identifiers[InsiderConstants.ADD_USER_ID] = userID;
@@ -47,7 +56,10 @@ class Identifier {
47
56
  }
48
57
 
49
58
  addCustomIdentifier(key, value) {
50
- if (key === null || value === null || Utils.isEmpty(key)){ Utils.showWarning(this.constructor.name + '-addCustomIdentifier key or value'); return this;}
59
+ if (Utils.checkParameters([{ type: 'string', value: key }, { type: 'string', value: value }])) {
60
+ Utils.showParameterWarningLog(this.constructor.name + '-addCustomIdentifier');
61
+ return this;
62
+ }
51
63
 
52
64
  try {
53
65
  this.identifiers[key] = value;