react-native-moengage 7.4.1 → 8.0.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +53 -1
  2. package/ReactNativeMoEngage.podspec +3 -3
  3. package/android/build.gradle +11 -12
  4. package/android/gradle/wrapper/gradle-wrapper.properties +3 -3
  5. package/android/gradle.properties +0 -1
  6. package/android/src/main/java/com/moengage/react/EventEmitterImpl.kt +46 -21
  7. package/android/src/main/java/com/moengage/react/MoEInitializer.kt +44 -13
  8. package/android/src/main/java/com/moengage/react/MoEReactBridge.kt +82 -85
  9. package/android/src/main/java/com/moengage/react/MoEReactHelper.kt +2 -2
  10. package/android/src/main/java/com/moengage/react/PayloadGenerator.kt +32 -17
  11. package/iOS/MoEReactBridge/MoEReactBridge.h +1 -1
  12. package/iOS/MoEReactBridge/MoEReactBridge.m +34 -60
  13. package/iOS/MoEReactBridge/{MOReactInitializer.h → MoEngageInitializer.h} +11 -11
  14. package/iOS/MoEReactBridge/MoEngageInitializer.m +153 -0
  15. package/iOS/MoEReactBridge/{MoEReactConstants.h → MoEngageReactConstants.h} +12 -3
  16. package/iOS/MoEReactBridge/{MoEReactConstants.m → MoEngageReactConstants.m} +13 -7
  17. package/iOS/MoEReactBridge/MoEngageReactPluginInfo.h +2 -0
  18. package/iOS/MoEReactBridge.xcodeproj/project.pbxproj +6 -6
  19. package/package.json +8 -3
  20. package/src/index.ts +134 -203
  21. package/src/models/MoEAccountMeta.ts +8 -0
  22. package/src/models/MoEAction.ts +4 -0
  23. package/src/models/MoEActionType.ts +4 -0
  24. package/src/models/MoECampaignContext.ts +10 -0
  25. package/src/models/MoECampaignData.ts +14 -0
  26. package/src/models/MoEClickData.ts +18 -0
  27. package/src/models/MoEGeoLocation.ts +2 -10
  28. package/src/models/MoEInAppCustomAction.ts +8 -13
  29. package/src/models/MoEInAppData.ts +16 -0
  30. package/src/models/MoEInAppNavigation.ts +14 -24
  31. package/src/models/MoENavigationType.ts +4 -0
  32. package/src/models/MoEPlatform.ts +4 -0
  33. package/src/models/MoEProperties.ts +19 -15
  34. package/src/models/MoEPushCampaign.ts +6 -22
  35. package/src/models/MoEPushPayload.ts +14 -0
  36. package/src/models/MoEPushService.ts +4 -4
  37. package/src/models/MoEPushToken.ts +6 -15
  38. package/src/models/MoESelfHandledCampaign.ts +10 -0
  39. package/src/models/MoESelfHandledCampaignData.ts +18 -0
  40. package/src/moeParser/MoEInAppParser.ts +192 -0
  41. package/src/moeParser/MoEPushNotificationParser.ts +78 -0
  42. package/src/platform/MoERNAndroid.ts +36 -92
  43. package/src/platform/MoERNiOS.ts +27 -60
  44. package/src/utils/MoEConstants.ts +59 -0
  45. package/src/utils/MoEEventHandlerHelper.ts +38 -25
  46. package/src/utils/MoEJsonBuilder.ts +220 -0
  47. package/src/utils/MoEObjectToJson.ts +44 -0
  48. package/iOS/MoEReactBridge/MOReactInitializer.m +0 -172
  49. package/iOS/MoEReactBridge/MOReactPluginInfo.h +0 -2
  50. package/src/models/MoEInAppCampaign.ts +0 -46
  51. package/src/models/MoEInAppSelfHandledCampaign.ts +0 -34
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Platform, NativeEventEmitter } from "react-native";
2
- import MoEInAppSelfHandledCampaign from "./models/MoEInAppSelfHandledCampaign";
3
2
  import MoEProperties from "./models/MoEProperties";
4
3
  import MoEGeoLocation from "./models/MoEGeoLocation";
5
4
  import * as MoEHelper from "./utils/MoEHelper";
@@ -8,15 +7,18 @@ import { MoEAppStatus } from "./models/MoEAppStatus";
8
7
  import { MoERNAndroid } from "./platform/MoERNAndroid";
9
8
  import { MoERNiOS } from "./platform/MoERNiOS";
10
9
 
11
- import MoEInAppCampaign from "./models/MoEInAppCampaign";
12
10
  import MoEInAppCustomAction from "./models/MoEInAppCustomAction";
13
11
  import MoEInAppNavigation from "./models/MoEInAppNavigation";
14
12
  import { executeHandler } from "./utils/MoEEventHandlerHelper";
13
+ import { getAdIdTrackingJson, getAliasJson, getAndroidIdTrackingJson, getAppIdJson, getAppStatusJson, getInAppCampaignJson, getInAppClickDataJson, getInAppContextJson, getMoEPropertiesJson, getMoEPushCampaignJson, getMoEPushTokenJson, getOptOutTrackingJson, getSdkStateJson, getSelfHandledJson, getUserAttributeJson, getUserLocAttributeJson } from "./utils/MoEJsonBuilder";
14
+ import { USER_ATTRIBUTE_UNIQUE_ID, USER_ATTRIBUTE_USER_BDAY, USER_ATTRIBUTE_USER_EMAIL, USER_ATTRIBUTE_USER_FIRST_NAME, USER_ATTRIBUTE_USER_GENDER, USER_ATTRIBUTE_USER_LAST_NAME, USER_ATTRIBUTE_USER_LOCATION, USER_ATTRIBUTE_USER_MOBILE, USER_ATTRIBUTE_USER_NAME } from "./utils/MoEConstants";
15
+ import MoESelfHandledCampaignData from "./models/MoESelfHandledCampaignData";
15
16
 
16
17
  const MoEReactBridge = require("react-native").NativeModules.MoEReactBridge;
17
18
  const PLATFORM_ANDROID = "android";
18
19
  const PLATFORM_IOS = "ios";
19
20
  const GENERAL = "general";
21
+ const TIMESTAMP = 'timestamp';
20
22
 
21
23
  const MOE_PUSH_CLICKED = "MoEPushClicked";
22
24
  const MOE_PUSH_REGISTERED = "MoEPushTokenGenerated";
@@ -45,6 +47,9 @@ const INAPP_DISMISSED = "inAppCampaignDismissed";
45
47
  const INAPP_CUTOM_ACTION = "inAppCampaignCustomAction";
46
48
  const INAPP_SELF_HANDLE = "inAppCampaignSelfHandled";
47
49
 
50
+ const PUSH_SERVICE_FCM = "FCM"
51
+ const PUSH_SERVICE_PUSH_KIT = "PUSH_KIT"
52
+
48
53
  const _eventNames = [
49
54
  PUSH_CLICKED,
50
55
  PUSH_REGISTERED,
@@ -56,7 +61,8 @@ const _eventNames = [
56
61
  ];
57
62
 
58
63
  var _eventTypeHandler = new Map();
59
- var MoeEventEmitter;
64
+ var MoeEventEmitter: { addListener: (arg0: any, arg1: (notification: any) => void) => void; };
65
+ var moeAppId = "";
60
66
 
61
67
  if (MoEReactBridge) {
62
68
  MoeEventEmitter = new NativeEventEmitter(MoEReactBridge);
@@ -65,8 +71,8 @@ if (MoEReactBridge) {
65
71
  }
66
72
  }
67
73
 
68
- function handleEventBroadcast(type, broadcast) {
69
- MoeEventEmitter.addListener(broadcast, (notification) => {
74
+ function handleEventBroadcast(type: string | String, broadcast: string) {
75
+ MoeEventEmitter.addListener(broadcast, (notification: any) => {
70
76
  executeHandler(_eventTypeHandler.get(type), notification, type);
71
77
  });
72
78
  }
@@ -84,22 +90,23 @@ function showError(message: String) {
84
90
  }
85
91
 
86
92
  var ReactMoE = {
87
- setEventListener: function (type, handler) {
93
+ setEventListener: function (type: any, handler: any) {
88
94
  if (!MoEReactBridge) return;
89
95
  _eventTypeHandler.set(type, handler);
90
96
  },
91
97
 
92
- removeEventListener: function (type) {
98
+ removeEventListener: function (type: any) {
93
99
  if (!MoEReactBridge) return;
94
100
  _eventTypeHandler.delete(type);
95
101
  },
96
102
 
97
- initialize: function () {
103
+ initialize: function (appId:string) {
104
+ moeAppId = appId;
98
105
  commonValidationCheck();
99
106
  if (Platform.OS == PLATFORM_ANDROID) {
100
- MoERNAndroid.initialize();
107
+ MoERNAndroid.initialize(getAppIdJson(appId));
101
108
  } else if (Platform.OS == PLATFORM_IOS) {
102
- MoERNiOS.initialize();
109
+ MoERNiOS.initialize(getAppIdJson(appId));
103
110
  }
104
111
  },
105
112
 
@@ -113,9 +120,7 @@ var ReactMoE = {
113
120
  setAppStatus: function (status: MoEAppStatus) {
114
121
  commonValidationCheck();
115
122
  console.log("Will track whether it is a fresh install or update.");
116
- let payload = {
117
- appStatus: MoEHelper.appStatusToString(status),
118
- };
123
+ let payload = getAppStatusJson(MoEHelper.appStatusToString(status),moeAppId);
119
124
  if (Platform.OS == PLATFORM_ANDROID) {
120
125
  MoERNAndroid.setAppStatus(payload);
121
126
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -130,22 +135,19 @@ var ReactMoE = {
130
135
  */
131
136
  trackEvent: function (eventName: String, properties: MoEProperties) {
132
137
  commonValidationCheck();
133
-
134
- if(properties == null) {
138
+
139
+ if (properties == null) {
135
140
  properties = new MoEProperties()
136
141
  }
137
-
142
+
138
143
  if (!(properties instanceof MoEProperties)) {
139
144
  showError("trackEvent: properties must of MoEProperties type");
140
145
  return;
141
146
  }
142
147
 
143
- console.log("trackEvent with properties", properties);
144
- //...(spread operator)it will append all the contents of the object/array into the target element
145
- let payload = {
146
- ...properties.toJSON(),
147
- eventName,
148
- };
148
+ console.log("trackEvent with properties", properties);
149
+ let payload= getMoEPropertiesJson(properties, eventName, moeAppId);
150
+
149
151
  if (Platform.OS == PLATFORM_ANDROID) {
150
152
  MoERNAndroid.trackEvent(payload);
151
153
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -160,11 +162,7 @@ var ReactMoE = {
160
162
  setUserUniqueID: function (uniqueId: string) {
161
163
  commonValidationCheck();
162
164
  console.log("Will set unique ID: " + uniqueId);
163
- const payload = MoEHelper.createUserAttributeParam(
164
- "USER_ATTRIBUTE_UNIQUE_ID",
165
- uniqueId,
166
- GENERAL
167
- );
165
+ const payload = getUserAttributeJson(USER_ATTRIBUTE_UNIQUE_ID,uniqueId,GENERAL,moeAppId)
168
166
  if (Platform.OS == PLATFORM_ANDROID) {
169
167
  MoERNAndroid.setUserAttribute(payload);
170
168
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -179,9 +177,7 @@ var ReactMoE = {
179
177
  setAlias: function (alias: string) {
180
178
  commonValidationCheck();
181
179
  console.log("Will set alias: " + alias);
182
- let payload = {
183
- alias: alias,
184
- };
180
+ let payload = getAliasJson(alias,moeAppId);
185
181
  if (Platform.OS == PLATFORM_ANDROID) {
186
182
  MoERNAndroid.setAlias(payload);
187
183
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -196,11 +192,8 @@ var ReactMoE = {
196
192
  setUserName: function (userName: string) {
197
193
  commonValidationCheck();
198
194
  console.log("Will set username: " + userName);
199
- const payload = MoEHelper.createUserAttributeParam(
200
- "USER_ATTRIBUTE_USER_NAME",
201
- userName,
202
- GENERAL
203
- );
195
+ const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_NAME,userName,GENERAL,moeAppId)
196
+
204
197
  if (Platform.OS == PLATFORM_ANDROID) {
205
198
  MoERNAndroid.setUserAttribute(payload);
206
199
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -215,11 +208,8 @@ var ReactMoE = {
215
208
  setUserFirstName: function (firstName: string) {
216
209
  commonValidationCheck();
217
210
  console.log("Will set first name: " + firstName);
218
- const payload = MoEHelper.createUserAttributeParam(
219
- "USER_ATTRIBUTE_USER_FIRST_NAME",
220
- firstName,
221
- GENERAL
222
- );
211
+ const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_FIRST_NAME,firstName,GENERAL,moeAppId)
212
+
223
213
  if (Platform.OS == PLATFORM_ANDROID) {
224
214
  MoERNAndroid.setUserAttribute(payload);
225
215
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -234,11 +224,8 @@ var ReactMoE = {
234
224
  setUserLastName: function (lastName: string) {
235
225
  commonValidationCheck();
236
226
  console.log("Will set last name: " + lastName);
237
- const payload = MoEHelper.createUserAttributeParam(
238
- "USER_ATTRIBUTE_USER_LAST_NAME",
239
- lastName,
240
- GENERAL
241
- );
227
+ const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_LAST_NAME,lastName,GENERAL,moeAppId)
228
+
242
229
  if (Platform.OS == PLATFORM_ANDROID) {
243
230
  MoERNAndroid.setUserAttribute(payload);
244
231
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -253,11 +240,8 @@ var ReactMoE = {
253
240
  setUserEmailID: function (emailId: string) {
254
241
  commonValidationCheck();
255
242
  console.log("Will set email-id " + emailId);
256
- const payload = MoEHelper.createUserAttributeParam(
257
- "USER_ATTRIBUTE_USER_EMAIL",
258
- emailId,
259
- GENERAL
260
- );
243
+ const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_EMAIL,emailId,GENERAL,moeAppId)
244
+
261
245
  if (Platform.OS == PLATFORM_ANDROID) {
262
246
  MoERNAndroid.setUserAttribute(payload);
263
247
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -272,11 +256,8 @@ var ReactMoE = {
272
256
  setUserContactNumber: function (mobileNumber: string) {
273
257
  commonValidationCheck();
274
258
  console.log("Will set Mobile Number: " + mobileNumber);
275
- const payload = MoEHelper.createUserAttributeParam(
276
- "USER_ATTRIBUTE_USER_MOBILE",
277
- mobileNumber,
278
- GENERAL
279
- );
259
+ const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_MOBILE,mobileNumber,GENERAL,moeAppId)
260
+
280
261
  if (Platform.OS == PLATFORM_ANDROID) {
281
262
  MoERNAndroid.setUserAttribute(payload);
282
263
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -291,11 +272,8 @@ var ReactMoE = {
291
272
  setUserBirthday: function (birthday: string) {
292
273
  commonValidationCheck();
293
274
  console.log("Will set birthday: " + birthday);
294
- const payload = MoEHelper.createUserAttributeParam(
295
- "USER_ATTRIBUTE_USER_BDAY",
296
- birthday,
297
- "timestamp"
298
- );
275
+ const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_BDAY,birthday,TIMESTAMP,moeAppId)
276
+
299
277
  if (Platform.OS == PLATFORM_ANDROID) {
300
278
  MoERNAndroid.setUserAttribute(payload);
301
279
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -307,14 +285,12 @@ var ReactMoE = {
307
285
  * Sets the gender of the user.
308
286
  * @param gender gender to be set
309
287
  */
310
- setUserGender: function (gender) {
288
+ setUserGender: function (gender: Object) {
311
289
  commonValidationCheck();
312
290
  console.log("Will set gender: " + gender);
313
- const payload = MoEHelper.createUserAttributeParam(
314
- "USER_ATTRIBUTE_USER_GENDER",
315
- gender,
316
- GENERAL
317
- );
291
+
292
+ const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_GENDER,gender,GENERAL,moeAppId)
293
+
318
294
  if (Platform.OS == PLATFORM_ANDROID) {
319
295
  MoERNAndroid.setUserAttribute(payload);
320
296
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -332,11 +308,8 @@ var ReactMoE = {
332
308
  showError("setUserLocation: location must of type MoEGeoLocation");
333
309
  return;
334
310
  }
335
- const payload = MoEHelper.createUserLocationAttributeParam(
336
- "USER_ATTRIBUTE_USER_LOCATION",
337
- location.latitude,
338
- location.longitude
339
- );
311
+ const payload = getUserLocAttributeJson(USER_ATTRIBUTE_USER_LOCATION,location.latitude,location.longitude,moeAppId)
312
+
340
313
  if (Platform.OS == PLATFORM_ANDROID) {
341
314
  MoERNAndroid.setUserAttribute(payload);
342
315
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -349,19 +322,16 @@ var ReactMoE = {
349
322
  * @param userAttributeName attribute name
350
323
  * @param userAttributeValue attribute value
351
324
  */
352
- setUserAttribute: function (userAttributeName: string, userAttributeValue) {
325
+ setUserAttribute: function (userAttributeName: string, userAttributeValue: Object) {
353
326
  commonValidationCheck();
354
327
  console.log(
355
328
  "Will track user attribute [attributeName]: " +
356
- userAttributeName +
357
- " attributeValue: " +
358
- userAttributeValue
359
- );
360
- const payload = MoEHelper.createUserAttributeParam(
361
- userAttributeName,
362
- userAttributeValue,
363
- GENERAL
329
+ userAttributeName +
330
+ " attributeValue: " +
331
+ userAttributeValue
364
332
  );
333
+ const payload = getUserAttributeJson(userAttributeName,userAttributeValue,GENERAL,moeAppId)
334
+
365
335
  if (Platform.OS == PLATFORM_ANDROID) {
366
336
  MoERNAndroid.setUserAttribute(payload);
367
337
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -379,11 +349,8 @@ var ReactMoE = {
379
349
  date: String
380
350
  ) {
381
351
  commonValidationCheck();
382
- const payload = MoEHelper.createUserAttributeParam(
383
- attributeName,
384
- date,
385
- "timestamp"
386
- );
352
+ const payload = getUserAttributeJson(attributeName,date,TIMESTAMP,moeAppId)
353
+
387
354
  if (Platform.OS == PLATFORM_ANDROID) {
388
355
  MoERNAndroid.setUserAttribute(payload);
389
356
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -407,11 +374,8 @@ var ReactMoE = {
407
374
  );
408
375
  return;
409
376
  }
410
- const payload = MoEHelper.createUserLocationAttributeParam(
411
- userAttributeName,
412
- location.latitude,
413
- location.longitude
414
- );
377
+ const payload = getUserLocAttributeJson(userAttributeName,location.latitude,location.longitude,moeAppId)
378
+
415
379
  if (Platform.OS == PLATFORM_ANDROID) {
416
380
  MoERNAndroid.setUserAttribute(payload);
417
381
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -426,9 +390,9 @@ var ReactMoE = {
426
390
  commonValidationCheck();
427
391
  console.log("Will logout user");
428
392
  if (Platform.OS == PLATFORM_ANDROID) {
429
- MoERNAndroid.logout();
393
+ MoERNAndroid.logout(getAppIdJson(moeAppId));
430
394
  } else if (Platform.OS == PLATFORM_IOS) {
431
- MoERNiOS.logout();
395
+ MoERNiOS.logout(getAppIdJson(moeAppId));
432
396
  }
433
397
  },
434
398
 
@@ -439,9 +403,9 @@ var ReactMoE = {
439
403
  commonValidationCheck();
440
404
  console.log("Will try to show in-app.");
441
405
  if (Platform.OS == PLATFORM_ANDROID) {
442
- MoERNAndroid.showInApp();
406
+ MoERNAndroid.showInApp(getAppIdJson(moeAppId));
443
407
  } else if (Platform.OS == PLATFORM_IOS) {
444
- MoERNiOS.showInApp();
408
+ MoERNiOS.showInApp(getAppIdJson(moeAppId));
445
409
  }
446
410
  },
447
411
 
@@ -451,25 +415,25 @@ var ReactMoE = {
451
415
  getSelfHandledInApp: function () {
452
416
  commonValidationCheck();
453
417
  if (Platform.OS == PLATFORM_ANDROID) {
454
- MoERNAndroid.getSelfHandledInApp();
418
+ MoERNAndroid.getSelfHandledInApp(getAppIdJson(moeAppId));
455
419
  } else if (Platform.OS == PLATFORM_IOS) {
456
- MoERNiOS.getSelfHandledInApp();
420
+ MoERNiOS.getSelfHandledInApp(getAppIdJson(moeAppId));
457
421
  }
458
422
  },
459
423
 
460
424
  /**
461
425
  * Call this method when you show the self handled in-app so we can update impressions.
462
- * @param {MoEInAppCampaign}campInfo : campaign information object
426
+ * @param {MoESelfHandledCampaignData}campInfo : campaign information object
463
427
  */
464
- selfHandledShown: function (inAppCampaign: MoEInAppCampaign) {
428
+ selfHandledShown: function (inAppCampaign: MoESelfHandledCampaignData) {
465
429
  commonValidationCheck();
466
- if (!(inAppCampaign instanceof MoEInAppCampaign)) {
430
+ if (!(inAppCampaign instanceof MoESelfHandledCampaignData)) {
467
431
  showError(
468
- "selfHandledShown: inAppCampaign must of MoEInAppCampaign type"
432
+ "selfHandledShown: inAppCampaign must of MoESelfHandledCampaignData type"
469
433
  );
470
434
  return;
471
435
  }
472
- let campaignJson = inAppCampaign.toJSON();
436
+ let campaignJson = getSelfHandledJson(inAppCampaign,"impression",moeAppId);
473
437
  if (Platform.OS == PLATFORM_ANDROID) {
474
438
  MoERNAndroid.selfHandledShown(campaignJson);
475
439
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -477,39 +441,19 @@ var ReactMoE = {
477
441
  }
478
442
  },
479
443
 
480
- /**
481
- * Call this method to track when self handled in app primary widget is clicked.
482
- * @param {MoEInAppCampaign}campInfo : campaign information object
483
- */
484
- selfHandledPrimaryClicked: function (inAppCampaign: MoEInAppCampaign) {
485
- commonValidationCheck();
486
- if (!(inAppCampaign instanceof MoEInAppCampaign)) {
487
- showError(
488
- "selfHandledClicked: inAppCampaign must of MoEInAppCampaign type"
489
- );
490
- return;
491
- }
492
- let campaignJson = inAppCampaign.toJSON();
493
- if (Platform.OS == PLATFORM_ANDROID) {
494
- MoERNAndroid.selfHandledPrimaryClicked(campaignJson);
495
- } else if (Platform.OS == PLATFORM_IOS) {
496
- MoERNiOS.selfHandledPrimaryClicked(campaignJson);
497
- }
498
- },
499
-
500
444
  /**
501
445
  * Call this method to track when self handled in app widget(other than Primary Widget) is clicked.
502
- * @param {MoEInAppCampaign}campInfo : campaign information object
446
+ * @param {MoESelfHandledCampaignData}campInfo : campaign information object
503
447
  */
504
- selfHandledClicked: function (inAppCampaign: MoEInAppCampaign) {
448
+ selfHandledClicked: function (moEClickData: MoESelfHandledCampaignData) {
505
449
  commonValidationCheck();
506
- if (!(inAppCampaign instanceof MoEInAppCampaign)) {
450
+ if (!(moEClickData instanceof MoESelfHandledCampaignData)) {
507
451
  showError(
508
- "selfHandledClicked: inAppCampaign must of MoEInAppCampaign type"
452
+ "selfHandledClicked: inAppCampaign must of MoEClickData type"
509
453
  );
510
454
  return;
511
455
  }
512
- let campaignJson = inAppCampaign.toJSON();
456
+ let campaignJson = getSelfHandledJson(moEClickData,"click",moeAppId);
513
457
  if (Platform.OS == PLATFORM_ANDROID) {
514
458
  MoERNAndroid.selfHandledClicked(campaignJson);
515
459
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -519,17 +463,17 @@ var ReactMoE = {
519
463
 
520
464
  /**
521
465
  * Call this method to track dismiss actions on the inApp.
522
- * @param {MoEInAppCampaign}campInfo : campaign information object
466
+ * @param {MoESelfHandledCampaignData}campInfo : campaign information object
523
467
  */
524
- selfHandledDismissed: function (inAppCampaign: MoEInAppCampaign) {
468
+ selfHandledDismissed: function (inAppCampaign: MoESelfHandledCampaignData) {
525
469
  commonValidationCheck();
526
- if (!(inAppCampaign instanceof MoEInAppCampaign)) {
470
+ if (!(inAppCampaign instanceof MoESelfHandledCampaignData)) {
527
471
  showError(
528
- "selfHandledDismissed: inAppCampaign must of MoEInAppCampaign type"
472
+ "selfHandledDismissed: inAppCampaign must of MoESelfHandledCampaignData type"
529
473
  );
530
474
  return;
531
475
  }
532
- let campaignJson = inAppCampaign.toJSON();
476
+ let campaignJson = getSelfHandledJson(inAppCampaign,"dismissed",moeAppId);
533
477
  if (Platform.OS == PLATFORM_ANDROID) {
534
478
  MoERNAndroid.selfHandledDismissed(campaignJson);
535
479
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -549,9 +493,7 @@ var ReactMoE = {
549
493
  );
550
494
  return;
551
495
  }
552
- let payload = {
553
- contexts: contexts,
554
- };
496
+ let payload = getInAppContextJson(contexts,moeAppId);
555
497
  if (Platform.OS == PLATFORM_ANDROID) {
556
498
  MoERNAndroid.setAppContext(payload);
557
499
  } else if (Platform.OS == PLATFORM_IOS) {
@@ -565,9 +507,9 @@ var ReactMoE = {
565
507
  resetCurrentContext: function () {
566
508
  commonValidationCheck();
567
509
  if (Platform.OS == PLATFORM_ANDROID) {
568
- MoERNAndroid.resetAppContext();
510
+ MoERNAndroid.resetAppContext(getAppIdJson(moeAppId));
569
511
  } else if (Platform.OS == PLATFORM_IOS) {
570
- MoERNiOS.resetAppContext();
512
+ MoERNiOS.resetAppContext(getAppIdJson(moeAppId));
571
513
  }
572
514
  },
573
515
 
@@ -580,8 +522,10 @@ var ReactMoE = {
580
522
  passFcmPushToken: function (pushToken: string) {
581
523
  commonValidationCheck();
582
524
  console.log("Will process push token");
525
+ let payload = getMoEPushTokenJson(pushToken,PUSH_SERVICE_FCM,PLATFORM_ANDROID,moeAppId);
526
+
583
527
  if (Platform.OS == PLATFORM_ANDROID) {
584
- MoERNAndroid.passFcmPushToken(pushToken);
528
+ MoERNAndroid.passFcmPushToken(payload);
585
529
  } else {
586
530
  console.log("This api is not supported on iOS platform.");
587
531
  }
@@ -595,23 +539,15 @@ var ReactMoE = {
595
539
  passFcmPushPayload: function (pushPayload: object) {
596
540
  commonValidationCheck();
597
541
  console.log("Will process push payload.");
542
+ let payload = getMoEPushCampaignJson(pushPayload,PUSH_SERVICE_FCM,moeAppId)
543
+
598
544
  if (Platform.OS == PLATFORM_ANDROID) {
599
- MoERNAndroid.passFcmPushPayload(pushPayload);
545
+ MoERNAndroid.passFcmPushPayload(payload);
600
546
  } else {
601
547
  console.log("This api is not supported on iOS platform.");
602
548
  }
603
549
  },
604
550
 
605
- enableSDKLogs: function () {
606
- commonValidationCheck();
607
- console.log("Enabling SDK logs");
608
- if (Platform.OS == PLATFORM_ANDROID) {
609
- MoERNAndroid.enableSDKLogs();
610
- } else if (Platform.OS == PLATFORM_IOS) {
611
- MoERNiOS.enableSDKLogs();
612
- }
613
- },
614
-
615
551
  /**
616
552
  * Call this method to register for push notification in iOS
617
553
  */
@@ -634,7 +570,7 @@ var ReactMoE = {
634
570
  if (Platform.OS == PLATFORM_ANDROID) {
635
571
  console.log("This api is not supported on android platform.");
636
572
  } else if (Platform.OS == PLATFORM_IOS) {
637
- MoERNiOS.disableInbox();
573
+ MoERNiOS.disableInbox(getAppIdJson(moeAppId));
638
574
  }
639
575
  },
640
576
 
@@ -645,74 +581,62 @@ var ReactMoE = {
645
581
  if (Platform.OS == PLATFORM_ANDROID) {
646
582
  //Android code
647
583
  } else if (Platform.OS == PLATFORM_IOS) {
648
- MoERNiOS.startGeofenceMonitoring();
584
+ MoERNiOS.startGeofenceMonitoring(getAppIdJson(moeAppId));
649
585
  }
650
586
  },
651
587
 
652
588
  optOutDataTracking: function (shouldOptOutDataTracking: boolean) {
653
589
  console.log("Will opt out data tracking");
590
+ let payload = getOptOutTrackingJson("data",shouldOptOutDataTracking,moeAppId);
654
591
  if (Platform.OS == PLATFORM_ANDROID) {
655
- MoERNAndroid.optOutDataTracking(shouldOptOutDataTracking);
656
- } else if (Platform.OS == PLATFORM_IOS) {
657
- MoERNiOS.optOutDataTracking(shouldOptOutDataTracking);
658
- }
659
- },
660
-
661
- optOutPushNotification: function (shouldOptOutPushNotification: boolean) {
662
- console.log("Will opt out push notifications");
663
- if (Platform.OS == PLATFORM_ANDROID) {
664
- MoERNAndroid.optOutPushNotification(shouldOptOutPushNotification);
665
- } else if (Platform.OS == PLATFORM_IOS) {
666
- MoERNiOS.optOutPushNotification(shouldOptOutPushNotification);
667
- }
668
- },
669
-
670
- optOutInAppNotification: function (shouldOptOutInApp: boolean) {
671
- console.log("Will opt out in-app notifications");
672
- if (Platform.OS == PLATFORM_ANDROID) {
673
- MoERNAndroid.optOutInAppNotification(shouldOptOutInApp);
592
+ MoERNAndroid.optOutDataTracking(payload);
674
593
  } else if (Platform.OS == PLATFORM_IOS) {
675
- MoERNiOS.optOutInAppNotification(shouldOptOutInApp);
594
+ MoERNiOS.optOutDataTracking(payload);
676
595
  }
677
596
  },
678
597
 
679
- /**
680
- * Pass the HMS PushKit push token to the MoEngage SDK.
681
- * Note: This API is only for Android platform and is a no-operation method for other plaforms.
682
- *
683
- * @param {String} pushToken
684
- */
685
- passPushKitPushToken: function (pushToken: string) {
598
+ /**
599
+ * Pass the HMS PushKit push token to the MoEngage SDK.
600
+ * Note: This API is only for Android platform and is a no-operation method for other plaforms.
601
+ *
602
+ * @param {String} pushToken
603
+ */
604
+ passPushKitPushToken: function (pushToken: string) {
686
605
  commonValidationCheck();
687
606
  console.log("Will process push-kit push token");
607
+ let payload = getMoEPushTokenJson(pushToken,PUSH_SERVICE_PUSH_KIT,PLATFORM_ANDROID,moeAppId);
608
+
688
609
  if (Platform.OS == PLATFORM_ANDROID) {
689
- MoERNAndroid.passPushKitPushToken(pushToken);
610
+ MoERNAndroid.passPushKitPushToken(payload);
690
611
  } else {
691
612
  console.log("This api is not supported on iOS platform.");
692
613
  }
693
614
  },
694
615
 
695
- enableSdk: function() {
616
+ enableSdk: function () {
696
617
  console.log("Will enable SDK");
697
- if(Platform.OS == PLATFORM_ANDROID) {
698
- MoERNAndroid.updateSdkState(true);
618
+ let payload = getSdkStateJson(true,moeAppId)
619
+ if (Platform.OS == PLATFORM_ANDROID) {
620
+ MoERNAndroid.updateSdkState(payload);
699
621
  } else if (Platform.OS == PLATFORM_IOS) {
700
- MoERNiOS.updateSdkState(true);
622
+ MoERNiOS.updateSdkState(payload);
701
623
  }
702
624
  },
703
625
 
704
- disableSdk: function() {
626
+ disableSdk: function () {
705
627
  console.log("Will disable SDK");
706
- if(Platform.OS == PLATFORM_ANDROID) {
707
- MoERNAndroid.updateSdkState(false);
628
+ let payload = getSdkStateJson(false,moeAppId)
629
+
630
+ if (Platform.OS == PLATFORM_ANDROID) {
631
+ MoERNAndroid.updateSdkState(payload);
708
632
  } else if (Platform.OS == PLATFORM_IOS) {
709
- MoERNiOS.updateSdkState(false);
633
+ MoERNiOS.updateSdkState(payload);
710
634
  }
711
635
  },
712
636
 
713
- onOrientationChanged: function() {
637
+ onOrientationChanged: function () {
714
638
  console.log("Will process screen rotation.");
715
- if(Platform.OS == PLATFORM_ANDROID) {
639
+ if (Platform.OS == PLATFORM_ANDROID) {
716
640
  MoERNAndroid.onOrientationChanged();
717
641
  }
718
642
  },
@@ -720,10 +644,12 @@ var ReactMoE = {
720
644
  /**
721
645
  * API to enable Advertising Id tracking for Android.
722
646
  */
723
- enableAdIdTracking: function() {
647
+ enableAdIdTracking: function () {
724
648
  console.log("Will enable advertising-id tracking");
725
- if(Platform.OS == PLATFORM_ANDROID) {
726
- MoERNAndroid.enableAdIdTracking();
649
+ let payload = getAdIdTrackingJson(true,moeAppId);
650
+
651
+ if (Platform.OS == PLATFORM_ANDROID) {
652
+ MoERNAndroid.enableAdIdTracking(payload);
727
653
  }
728
654
  },
729
655
 
@@ -733,20 +659,24 @@ var ReactMoE = {
733
659
  * By default Advertising Id tracking is disabled, call this method only if you have enabled
734
660
  * Advertising Id tracking at some point.
735
661
  */
736
- disableAdIdTracking: function() {
662
+ disableAdIdTracking: function () {
737
663
  console.log("Will disable advertising-id tracking");
738
- if(Platform.OS == PLATFORM_ANDROID) {
739
- MoERNAndroid.disableAdIdTracking();
664
+ let payload = getAdIdTrackingJson(false,moeAppId);
665
+
666
+ if (Platform.OS == PLATFORM_ANDROID) {
667
+ MoERNAndroid.disableAdIdTracking(payload);
740
668
  }
741
669
  },
742
670
 
743
671
  /**
744
672
  * API to enable Android Id tracking for Android.
745
673
  */
746
- enableAndroidIdTracking: function() {
674
+ enableAndroidIdTracking: function () {
747
675
  console.log("Will enable android-id tracking");
748
- if(Platform.OS == PLATFORM_ANDROID) {
749
- MoERNAndroid.enableAndroidIdTracking();
676
+ let payload = getAndroidIdTrackingJson(true,moeAppId);
677
+
678
+ if (Platform.OS == PLATFORM_ANDROID) {
679
+ MoERNAndroid.enableAndroidIdTracking(payload);
750
680
  }
751
681
  },
752
682
 
@@ -756,21 +686,22 @@ var ReactMoE = {
756
686
  * By default Android Id tracking is disabled, call this method only if you have enabled
757
687
  * Advertising Id tracking at some point.
758
688
  */
759
- disableAndroidIdTracking: function() {
689
+ disableAndroidIdTracking: function () {
760
690
  console.log("Will disable android-id tracking");
761
- if(Platform.OS == PLATFORM_ANDROID) {
762
- MoERNAndroid.disableAndroidIdTracking();
691
+ let payload = getAndroidIdTrackingJson(false,moeAppId);
692
+
693
+ if (Platform.OS == PLATFORM_ANDROID) {
694
+ MoERNAndroid.disableAndroidIdTracking(payload);
763
695
  }
764
696
  }
765
-
697
+
766
698
 
767
699
  };
768
700
 
769
701
  export {
770
- MoEInAppCampaign,
771
702
  MoEInAppCustomAction,
772
703
  MoEInAppNavigation,
773
- MoEInAppSelfHandledCampaign,
704
+ MoESelfHandledCampaignData,
774
705
  MoEGeoLocation,
775
706
  MoEProperties,
776
707
  MoEAppStatus,