reactnative-plugin-appice 1.7.17 → 1.7.19

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.
@@ -113,7 +113,7 @@ dependencies {
113
113
  annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
114
114
 
115
115
  //appice
116
- implementation 'appice.io.android:sdk:2.5.81'
116
+ implementation 'appice.io.android:sdk:2.5.84'
117
117
 
118
118
  //glide
119
119
  implementation "com.github.bumptech.glide:glide:4.11.0"
@@ -22,6 +22,8 @@ import org.json.JSONObject;
22
22
  import semusi.context.ui.appInbox.AppICEInboxMessage;
23
23
  import semusi.activitysdk.User;
24
24
 
25
+ import semusi.nativedisplay.Campaign;
26
+
25
27
  public class AppICEUtils {
26
28
  private static final String TAG = "AppICEUtils";
27
29
 
@@ -45,6 +47,38 @@ public class AppICEUtils {
45
47
  return inboxObject;
46
48
  }
47
49
 
50
+ /**
51
+ * This method accept object of native Campaign class (semusi.nativedisplay.Campaign)
52
+ * and convert to WritableMap for hybrid side
53
+ *
54
+ * @param campaign object of native Campaign class
55
+ * @return WritableMap
56
+ */
57
+ public static WritableMap convertClassToWritableMap(Campaign campaign) {
58
+ WritableMap campaignMap = Arguments.createMap();
59
+ try {
60
+ if (campaign != null) {
61
+ campaignMap.putString(EnumConstants.CAMP_ID.getValue(), campaign.getCampId());
62
+ campaignMap.putString(EnumConstants.ACTION_URL.getValue(), campaign.getActionUrl());
63
+ campaignMap.putString(EnumConstants.ACTION_TYPE.getValue(), campaign.getActionType());
64
+
65
+ JSONObject cdata = campaign.getcustomData();
66
+ Map<String, Object> customDataMap = new HashMap<>();
67
+ Iterator<String> keys = cdata.keys();
68
+
69
+ while (keys.hasNext()) {
70
+ String key = keys.next();
71
+ customDataMap.put(key, cdata.getString(key));
72
+ }
73
+
74
+ campaignMap.putMap(EnumConstants.CUSTOMDATA.getValue(), toWritableMap(customDataMap));
75
+ }
76
+ } catch (Throwable e) {
77
+
78
+ }
79
+ return campaignMap;
80
+ }
81
+
48
82
  /**
49
83
  * This method accept object of native User class (semusi.activitysdk.User)
50
84
  * and convert to WritableMap for hybrid side
@@ -75,6 +109,8 @@ public class AppICEUtils {
75
109
  return userObject;
76
110
  }
77
111
 
112
+
113
+
78
114
  public static WritableMap toWritableMap(Map<String, Object> map) {
79
115
  WritableMap writableMap = Arguments.createMap();
80
116
  Iterator iterator = map.entrySet().iterator();
@@ -239,4 +275,5 @@ public class AppICEUtils {
239
275
  public static void printLog(String TAG, String message) {
240
276
  System.out.println(TAG + ", " + message);
241
277
  }
278
+
242
279
  }
@@ -42,6 +42,9 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
42
42
  import org.json.JSONException;
43
43
  import org.json.JSONObject;
44
44
 
45
+ import semusi.nativedisplay.Campaign;
46
+ import semusi.nativedisplay.NativeDisplayDataProvider;
47
+
45
48
  public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
46
49
  private static ReactApplicationContext context = null;
47
50
  private static final String TAG = "AppIceReactPlugin";
@@ -171,7 +174,6 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
171
174
  }
172
175
  }
173
176
 
174
-
175
177
  @ReactMethod
176
178
  public void setCustomVariable(String eventName, String value) {
177
179
  Context context = getReactApplicationContext();
@@ -672,6 +674,10 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
672
674
  constants.put(EnumConstants.AVERAGE_TRANSACTION_AMOUNT.getConstants(), EnumConstants.AVERAGE_TRANSACTION_AMOUNT.getValue());
673
675
  constants.put(EnumConstants.FREQUENCY_OF_TRANSACTION.getConstants(), EnumConstants.FREQUENCY_OF_TRANSACTION.getValue());
674
676
  constants.put(EnumConstants.TYPE_OF_TRANSACTION.getConstants(), EnumConstants.TYPE_OF_TRANSACTION.getValue());
677
+ constants.put(EnumConstants.CAMP_ID.getConstants(), EnumConstants.CAMP_ID.getValue());
678
+ constants.put(EnumConstants.ACTION_URL.getConstants(), EnumConstants.ACTION_URL.getValue());
679
+ constants.put(EnumConstants.ACTION_TYPE.getConstants(), EnumConstants.ACTION_TYPE.getValue());
680
+ constants.put(EnumConstants.CUSTOMDATA.getConstants(), EnumConstants.CUSTOMDATA.getValue());
675
681
 
676
682
  return constants;
677
683
  }
@@ -744,6 +750,29 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
744
750
  }else {
745
751
  callback.invoke(null, StringConstants.INVALID_INBOX_FORMAT);
746
752
  }
753
+ }
754
+
755
+ @ReactMethod
756
+ public void getCampaigns(String type, Callback callback) {
757
+ Context context = getReactApplicationContext();
758
+ WritableArray writableArray = Arguments.createArray();
759
+ try{
760
+ List<Campaign> campaigns = ContextSdk.getCampaigns(type, context);
761
+ for (int i = 0; i < campaigns.size(); i++) {
762
+ Campaign campaign = campaigns.get(i);
763
+ writableArray.pushMap(AppICEUtils.convertClassToWritableMap(campaign));
764
+ }
765
+ callback.invoke(writableArray);
766
+ }
767
+ catch(Throwable e){
768
+ callback.invoke(e.getMessage());
769
+ }
770
+ }
747
771
 
772
+ @ReactMethod
773
+ public void getCampaignById(String cmpId,Callback callback) {
774
+ Context context = getReactApplicationContext();
775
+ Campaign campaign = ContextSdk.getCampaignById(cmpId, context);
776
+ callback.invoke(AppICEUtils.convertClassToWritableMap(campaign));
748
777
  }
749
778
  }
@@ -4,6 +4,7 @@ import semusi.context.utility.AppICEConstants;
4
4
  import semusi.activitysdk.CustomUserPropertyConstants;
5
5
  import semusi.activitysdk.Ecommerce;
6
6
  import semusi.activitysdk.FinancialServices;
7
+ import semusi.nativedisplay.Campaign;
7
8
  //Common place for constant and SDK constants
8
9
  public enum EnumConstants {
9
10
 
@@ -76,8 +77,17 @@ public enum EnumConstants {
76
77
  CHECKING_BALANCE("CHECKING_BALANCE"),
77
78
  AVERAGE_TRANSACTION_AMOUNT("AVERAGE_TRANSACTION_AMOUNT"),
78
79
  FREQUENCY_OF_TRANSACTION("FREQUENCY_OF_TRANSACTION"),
79
- TYPE_OF_TRANSACTION("TYPE_OF_TRANSACTION");
80
+ TYPE_OF_TRANSACTION("TYPE_OF_TRANSACTION"),
80
81
 
82
+
83
+ //====================
84
+ // CampaignData
85
+ //====================
86
+ CAMP_ID("CAMP_ID"),
87
+ ACTION_URL("ACTION_URL"),
88
+ ACTION_TYPE("ACTION_TYPE"),
89
+ CUSTOMDATA("CUSTOMDATA");
90
+
81
91
  private String constants;
82
92
 
83
93
  EnumConstants(String constants) {
@@ -249,6 +259,19 @@ public enum EnumConstants {
249
259
  case "TYPE_OF_TRANSACTION":{
250
260
  return FinancialServices.TYPE_OF_TRANSACTION;
251
261
  }
262
+
263
+ case "CAMP_ID":{
264
+ return Campaign.CAMP_ID;
265
+ }
266
+ case "ACTION_URL":{
267
+ return Campaign.ACTION_URL;
268
+ }
269
+ case "ACTION_TYPE":{
270
+ return Campaign.ACTION_TYPE;
271
+ }
272
+ case "CUSTOMDATA":{
273
+ return Campaign.CUSTOMDATA;
274
+ }
252
275
  default:
253
276
  return "";
254
277
  }
package/example/App.js CHANGED
@@ -30,13 +30,13 @@ const HelloWorldApp = () => {
30
30
  AppICE.preInitialise();
31
31
  console.log('preInitialize completed');
32
32
 
33
- AppICE.startContext(
34
- "5bebe93c25d705690ffbc758",
35
- "9e9ec60197c8373a11ac15ce4dae80e973608ab2",
36
- "e5aa4b293f3188fac9cb1a4017963604",
33
+ AppICE.startContext( //keys here
34
+ "",
35
+ "",
36
+ "",
37
+ "",
38
+ "",
37
39
  "",
38
- "US",
39
- "https://a.appice.io",
40
40
  certs
41
41
  );
42
42
 
@@ -78,6 +78,8 @@ const HelloWorldApp = () => {
78
78
  <Button onPress={synchronizeInbox} title="synchronizeInbox" color="#841584" />
79
79
  <Button onPress={getUserDetails} title="getUserDetails" color="#841584" />
80
80
  <Button onPress={getUserData} title="getUserData" color="#841584" />
81
+ <Button onPress={getCampaignById} title="getCampaignById" color="#841584" />
82
+ <Button onPress={getCampaigns} title="getCampaigns" color="#841584" />
81
83
 
82
84
  </View>
83
85
  );
@@ -115,6 +117,8 @@ function addAppICEAPIListeners() {
115
117
  },
116
118
  );
117
119
  }
120
+
121
+
118
122
  const sendEvent = () => {
119
123
  console.log('inside sendEvent');
120
124
  var dataObj = {
@@ -291,5 +295,38 @@ const getUserData = () => {
291
295
  AppICE.tagEvent(event, segment, flush)
292
296
  }
293
297
 
298
+ // getCampaigns
299
+
300
+ const getCampaigns = () => {
301
+
302
+ const type = AppICE.CampaignType.NATIVE;
303
+
304
+ AppICE.getCampaigns(type, (campaigns: any[]) => {
305
+ console.log('Campaigns:', campaigns);
306
+
307
+ campaigns.forEach((campaign) => {
308
+
309
+ console.log('getCampaigns of Campaign ID:', campaign.getCampaignId());
310
+ console.log('Action URL is :', campaign.getActionUrl());
311
+ console.log('Action Type is :', campaign.getActionType());
312
+ console.log('Custom Data is :', campaign.getCustomData());
313
+
314
+ });
315
+ });
316
+ };
317
+
318
+ const getCampaignById = () => {
319
+
320
+ const cmpId = '1234';
321
+ AppICE.getCampaignById(cmpId, (campaign: any) => {
322
+
323
+ console.log('getCampaignById of Campaign ID:', campaign.getCampaignId());
324
+ console.log('Action URL is :', campaign.getActionUrl());
325
+ console.log('Action Type is :', campaign.getActionType());
326
+ console.log('Custom Data is :', campaign.getCustomData());
327
+
328
+ });
329
+ };
330
+
294
331
 
295
332
  export default HelloWorldApp;
File without changes
@@ -17,7 +17,7 @@
17
17
  "install": "^0.13.0",
18
18
  "react": "18.0.0",
19
19
  "react-native": "0.69.4",
20
- "reactnative-plugin-appice": "1.7.16",
20
+ "reactnative-plugin-appice": "1.7.19",
21
21
  "react-native-mmkv": "2.12.2"
22
22
  },
23
23
  "devDependencies": {