react-native-moengage 9.1.0 → 10.0.1
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/CHANGELOG.md +31 -0
- package/ReactNativeMoEngage.podspec +8 -1
- package/android/build.gradle +23 -7
- package/android/src/main/java/com/moengage/react/{MoEReactBridge.kt → MoEReactBridgeHandler.kt} +29 -70
- package/android/src/main/java/com/moengage/react/MoEReactPackage.kt +39 -9
- package/android/src/newarch/com/moengage/react/MoEReactBridge.kt +143 -0
- package/android/src/oldarch/com/moengage/react/MoEReactBridge.kt +172 -0
- package/iOS/MoEReactBridge/MoEReactBridge.h +12 -1
- package/iOS/MoEReactBridge/MoEReactBridge.mm +245 -0
- package/iOS/MoEReactBridge/MoEReactNativeHandler.h +36 -0
- package/iOS/MoEReactBridge/MoEReactNativeHandler.m +138 -0
- package/iOS/MoEReactBridge/MoEngageInitializer.h +0 -28
- package/iOS/MoEReactBridge/MoEngageInitializer.m +3 -115
- package/iOS/MoEReactBridge/MoEngageReactPluginInfo.h +1 -1
- package/iOS/MoEReactBridge/MoEngageReactUtils.h +1 -0
- package/iOS/MoEReactBridge/MoEngageReactUtils.m +6 -0
- package/package.json +9 -1
- package/src/NativeMoEngage.ts +201 -0
- package/src/index.ts +195 -302
- package/src/moeParser/MoEngagePayloadParser.ts +1 -1
- package/src/utils/MoEJsonBuilder.ts +23 -22
- package/iOS/MoEReactBridge/MoEReactBridge.m +0 -197
- package/src/platform/MoERNAndroid.ts +0 -172
- package/src/platform/MoERNiOS.ts +0 -91
package/src/index.ts
CHANGED
|
@@ -1,49 +1,46 @@
|
|
|
1
|
-
import {NativeEventEmitter, Platform} from "react-native";
|
|
1
|
+
import { NativeEventEmitter, Platform } from "react-native";
|
|
2
2
|
import MoEProperties from "./models/MoEProperties";
|
|
3
3
|
import MoEGeoLocation from "./models/MoEGeoLocation";
|
|
4
4
|
import * as MoEHelper from "./utils/MoEHelper";
|
|
5
5
|
|
|
6
|
-
import {MoEAppStatus} from "./models/MoEAppStatus";
|
|
7
|
-
import {MoERNAndroid} from "./platform/MoERNAndroid";
|
|
8
|
-
import {MoERNiOS} from "./platform/MoERNiOS";
|
|
9
|
-
|
|
6
|
+
import { MoEAppStatus } from "./models/MoEAppStatus";
|
|
10
7
|
import MoEInAppCustomAction from "./models/MoEInAppCustomAction";
|
|
11
8
|
import MoEInAppNavigation from "./models/MoEInAppNavigation";
|
|
12
|
-
import {executeHandler} from "./utils/MoEEventHandlerHelper";
|
|
13
|
-
|
|
9
|
+
import { executeHandler } from "./utils/MoEEventHandlerHelper";
|
|
14
10
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
getAdIdTrackingJson,
|
|
12
|
+
getAliasJson,
|
|
13
|
+
getAndroidIdTrackingJson,
|
|
14
|
+
getAppIdJson,
|
|
15
|
+
getAppStatusJson,
|
|
16
|
+
getInAppContextJson,
|
|
17
|
+
getMoEPropertiesJson,
|
|
18
|
+
getMoEPushCampaignJson,
|
|
19
|
+
getMoEPushTokenJson,
|
|
20
|
+
getOptOutTrackingJson,
|
|
21
|
+
getSdkStateJson,
|
|
22
|
+
getSelfHandledJson,
|
|
23
|
+
getUserAttributeJson,
|
|
24
|
+
getUserLocAttributeJson,
|
|
25
|
+
getPushPermissionRequestCountJson,
|
|
26
|
+
getDeviceIdTrackingJson,
|
|
27
|
+
getInitConfigJson,
|
|
28
|
+
getPermissionResponseJson,
|
|
29
|
+
getNudgeDisplayJson
|
|
33
30
|
} from "./utils/MoEJsonBuilder";
|
|
34
31
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
USER_ATTRIBUTE_UNIQUE_ID,
|
|
33
|
+
USER_ATTRIBUTE_USER_BDAY,
|
|
34
|
+
USER_ATTRIBUTE_USER_EMAIL,
|
|
35
|
+
USER_ATTRIBUTE_USER_FIRST_NAME,
|
|
36
|
+
USER_ATTRIBUTE_USER_GENDER,
|
|
37
|
+
USER_ATTRIBUTE_USER_LAST_NAME,
|
|
38
|
+
USER_ATTRIBUTE_USER_LOCATION,
|
|
39
|
+
USER_ATTRIBUTE_USER_MOBILE,
|
|
40
|
+
USER_ATTRIBUTE_USER_NAME
|
|
44
41
|
} from "./utils/MoEConstants";
|
|
45
42
|
import MoESelfHandledCampaignData from "./models/MoESelfHandledCampaignData";
|
|
46
|
-
import {MoEngagePermissionType} from "./models/MoEngagePermissionType";
|
|
43
|
+
import { MoEngagePermissionType } from "./models/MoEngagePermissionType";
|
|
47
44
|
import MoEInitConfig from "./models/MoEInitConfig";
|
|
48
45
|
import MoEPushConfig from "./models/MoEPushConfig";
|
|
49
46
|
import MoEngageLogConfig from "./models/MoEngageLogConfig";
|
|
@@ -52,11 +49,16 @@ import MoEngageGlobalCache from "./utils/MoEngageGlobalCache";
|
|
|
52
49
|
import MoEngageLogger from "./logger/MoEngageLogger";
|
|
53
50
|
import UserDeletionData from "./models/UserDeletionData";
|
|
54
51
|
import MoEAccountMeta from "./models/MoEAccountMeta";
|
|
55
|
-
import { MoEngageNudgePosition } from "./models/MoEngageNudgePosition";
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
import MoEReactBridge from "./NativeMoEngage";
|
|
54
|
+
import MoEPushToken from "../src/models/MoEPushToken";
|
|
55
|
+
import MoEPushPayload from "../src/models/MoEPushPayload";
|
|
56
|
+
import MoEInAppData from "../src/models/MoEInAppData";
|
|
57
|
+
import { getUserDeletionData } from "../src/moeParser/MoEngagePayloadParser";
|
|
58
|
+
import { MoEngageNudgePosition } from "../src/models/MoEngageNudgePosition";
|
|
59
|
+
|
|
59
60
|
const PLATFORM_IOS = "ios";
|
|
61
|
+
const PLATFORM_ANDROID = "android";
|
|
60
62
|
const GENERAL = "general";
|
|
61
63
|
const TIMESTAMP = 'timestamp';
|
|
62
64
|
|
|
@@ -105,11 +107,11 @@ const _eventNames = [
|
|
|
105
107
|
];
|
|
106
108
|
|
|
107
109
|
var _eventTypeHandler = new Map();
|
|
108
|
-
var MoeEventEmitter: { addListener: (arg0: any, arg1: (notification: any) => void) => void; };
|
|
109
110
|
var moeAppId = "";
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
const eventEmitter = new NativeEventEmitter(MoEReactBridge as any);
|
|
113
|
+
|
|
114
|
+
if (eventEmitter) {
|
|
113
115
|
for (var i = 0; i < eventBroadcastNames.length; i++) {
|
|
114
116
|
let eventName = _eventNames[i];
|
|
115
117
|
let eventBroadcastName = eventBroadcastNames[i];
|
|
@@ -120,23 +122,27 @@ if (MoEReactBridge) {
|
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
function handleEventBroadcast(type: string | String, broadcast: string) {
|
|
123
|
-
|
|
125
|
+
eventEmitter?.addListener(broadcast, (notification: any) => {
|
|
124
126
|
executeHandler(_eventTypeHandler.get(type), notification, type);
|
|
125
127
|
});
|
|
126
128
|
}
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
export type NotificationEventName = 'pushTokenGenerated' | 'pushClicked' | 'inAppCampaignShown' | 'inAppCampaignClicked' | 'inAppCampaignDismissed' | 'inAppCampaignCustomAction' | 'inAppCampaignSelfHandled';
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
type NotificationEventTypeMap = {
|
|
134
|
+
"pushTokenGenerated": MoEPushToken,
|
|
135
|
+
"pushClicked": MoEPushPayload,
|
|
136
|
+
"inAppCampaignShown": MoEInAppData,
|
|
137
|
+
"inAppCampaignClicked": MoEInAppData,
|
|
138
|
+
"inAppCampaignDismissed": MoEInAppData,
|
|
139
|
+
"inAppCampaignCustomAction": MoEInAppData,
|
|
140
|
+
"inAppCampaignSelfHandled": MoESelfHandledCampaignData
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
var ReactMoE = {
|
|
137
|
-
setEventListener: function (
|
|
138
|
-
|
|
139
|
-
_eventTypeHandler.set(type, handler);
|
|
144
|
+
setEventListener: function <T extends NotificationEventName>(event: T, listener: (callback: NotificationEventTypeMap[T]) => void): void {
|
|
145
|
+
_eventTypeHandler.set(event, listener);
|
|
140
146
|
},
|
|
141
147
|
|
|
142
148
|
removeEventListener: function (type: any) {
|
|
@@ -153,12 +159,15 @@ var ReactMoE = {
|
|
|
153
159
|
initialize: function (appId: string, initConfig: MoEInitConfig = MoEInitConfig.defaultConfig()) {
|
|
154
160
|
moeAppId = appId;
|
|
155
161
|
MoEngageGlobalCache.updateInitConfig(initConfig);
|
|
156
|
-
|
|
162
|
+
let payload: string = "";
|
|
157
163
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
158
|
-
|
|
164
|
+
payload = getInitConfigJson(appId, initConfig);
|
|
159
165
|
} else if (Platform.OS == PLATFORM_IOS) {
|
|
160
|
-
|
|
166
|
+
payload = getAppIdJson(appId);
|
|
161
167
|
}
|
|
168
|
+
|
|
169
|
+
MoEngageLogger.verbose("Initializing the MoEngage Plugin");
|
|
170
|
+
MoEReactBridge.initialize(payload);
|
|
162
171
|
},
|
|
163
172
|
|
|
164
173
|
/**
|
|
@@ -169,14 +178,9 @@ var ReactMoE = {
|
|
|
169
178
|
* @param isExisting true if it is an existing user else set false
|
|
170
179
|
*/
|
|
171
180
|
setAppStatus: function (status: MoEAppStatus) {
|
|
172
|
-
commonValidationCheck();
|
|
173
181
|
MoEngageLogger.verbose("Will track whether it is a fresh install or update.");
|
|
174
182
|
let payload = getAppStatusJson(MoEHelper.appStatusToString(status), moeAppId);
|
|
175
|
-
|
|
176
|
-
MoERNAndroid.setAppStatus(payload);
|
|
177
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
178
|
-
MoERNiOS.setAppStatus(payload);
|
|
179
|
-
}
|
|
183
|
+
MoEReactBridge.setAppStatus(payload);
|
|
180
184
|
},
|
|
181
185
|
|
|
182
186
|
/**
|
|
@@ -185,8 +189,6 @@ var ReactMoE = {
|
|
|
185
189
|
* @param {MoEProperties}properties : properties of the event
|
|
186
190
|
*/
|
|
187
191
|
trackEvent: function (eventName: String, properties: MoEProperties) {
|
|
188
|
-
commonValidationCheck();
|
|
189
|
-
|
|
190
192
|
if (properties == null) {
|
|
191
193
|
properties = new MoEProperties()
|
|
192
194
|
}
|
|
@@ -198,12 +200,7 @@ var ReactMoE = {
|
|
|
198
200
|
|
|
199
201
|
MoEngageLogger.verbose("trackEvent with properties", properties);
|
|
200
202
|
let payload = getMoEPropertiesJson(properties, eventName, moeAppId);
|
|
201
|
-
|
|
202
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
203
|
-
MoERNAndroid.trackEvent(payload);
|
|
204
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
205
|
-
MoERNiOS.trackEvent(payload);
|
|
206
|
-
}
|
|
203
|
+
MoEReactBridge.trackEvent(payload);
|
|
207
204
|
},
|
|
208
205
|
|
|
209
206
|
/**
|
|
@@ -211,14 +208,9 @@ var ReactMoE = {
|
|
|
211
208
|
* @param uniqueId unique id to be set
|
|
212
209
|
*/
|
|
213
210
|
setUserUniqueID: function (uniqueId: string) {
|
|
214
|
-
commonValidationCheck();
|
|
215
211
|
MoEngageLogger.verbose("Will set unique ID: ", uniqueId);
|
|
216
212
|
const payload = getUserAttributeJson(USER_ATTRIBUTE_UNIQUE_ID, uniqueId, GENERAL, moeAppId);
|
|
217
|
-
|
|
218
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
219
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
220
|
-
MoERNiOS.setUserAttribute(payload);
|
|
221
|
-
}
|
|
213
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
222
214
|
},
|
|
223
215
|
|
|
224
216
|
/**
|
|
@@ -226,14 +218,9 @@ var ReactMoE = {
|
|
|
226
218
|
* @param alias updated unique id.
|
|
227
219
|
*/
|
|
228
220
|
setAlias: function (alias: string) {
|
|
229
|
-
commonValidationCheck();
|
|
230
221
|
MoEngageLogger.verbose("Will set alias: ", alias);
|
|
231
222
|
let payload = getAliasJson(alias, moeAppId);
|
|
232
|
-
|
|
233
|
-
MoERNAndroid.setAlias(payload);
|
|
234
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
235
|
-
MoERNiOS.setAlias(payload);
|
|
236
|
-
}
|
|
223
|
+
MoEReactBridge.setAlias(payload);
|
|
237
224
|
},
|
|
238
225
|
|
|
239
226
|
/**
|
|
@@ -241,15 +228,9 @@ var ReactMoE = {
|
|
|
241
228
|
* @param userName user-name to be set
|
|
242
229
|
*/
|
|
243
230
|
setUserName: function (userName: string) {
|
|
244
|
-
commonValidationCheck();
|
|
245
231
|
MoEngageLogger.verbose("Will set username: ", userName);
|
|
246
232
|
const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_NAME, userName, GENERAL, moeAppId);
|
|
247
|
-
|
|
248
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
249
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
250
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
251
|
-
MoERNiOS.setUserAttribute(payload);
|
|
252
|
-
}
|
|
233
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
253
234
|
},
|
|
254
235
|
|
|
255
236
|
/**
|
|
@@ -257,15 +238,9 @@ var ReactMoE = {
|
|
|
257
238
|
* @param firstName first name to be set
|
|
258
239
|
*/
|
|
259
240
|
setUserFirstName: function (firstName: string) {
|
|
260
|
-
commonValidationCheck();
|
|
261
241
|
MoEngageLogger.verbose("Will set first name: ", firstName);
|
|
262
242
|
const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_FIRST_NAME, firstName, GENERAL, moeAppId);
|
|
263
|
-
|
|
264
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
265
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
266
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
267
|
-
MoERNiOS.setUserAttribute(payload);
|
|
268
|
-
}
|
|
243
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
269
244
|
},
|
|
270
245
|
|
|
271
246
|
/**
|
|
@@ -273,15 +248,9 @@ var ReactMoE = {
|
|
|
273
248
|
* @param lastName last name to be set
|
|
274
249
|
*/
|
|
275
250
|
setUserLastName: function (lastName: string) {
|
|
276
|
-
commonValidationCheck();
|
|
277
251
|
MoEngageLogger.verbose("Will set last name: ", lastName);
|
|
278
252
|
const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_LAST_NAME, lastName, GENERAL, moeAppId);
|
|
279
|
-
|
|
280
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
281
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
282
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
283
|
-
MoERNiOS.setUserAttribute(payload);
|
|
284
|
-
}
|
|
253
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
285
254
|
},
|
|
286
255
|
|
|
287
256
|
/**
|
|
@@ -289,15 +258,9 @@ var ReactMoE = {
|
|
|
289
258
|
* @param emailId email-id to be set
|
|
290
259
|
*/
|
|
291
260
|
setUserEmailID: function (emailId: string) {
|
|
292
|
-
commonValidationCheck();
|
|
293
261
|
MoEngageLogger.verbose("Will set email-id ", emailId);
|
|
294
262
|
const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_EMAIL, emailId, GENERAL, moeAppId);
|
|
295
|
-
|
|
296
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
297
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
298
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
299
|
-
MoERNiOS.setUserAttribute(payload);
|
|
300
|
-
}
|
|
263
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
301
264
|
},
|
|
302
265
|
|
|
303
266
|
/**
|
|
@@ -305,14 +268,9 @@ var ReactMoE = {
|
|
|
305
268
|
* @param mobileNumber mobile number to be set
|
|
306
269
|
*/
|
|
307
270
|
setUserContactNumber: function (mobileNumber: string) {
|
|
308
|
-
commonValidationCheck();
|
|
309
271
|
MoEngageLogger.verbose("Will set Mobile Number: ", mobileNumber);
|
|
310
272
|
const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_MOBILE, mobileNumber, GENERAL, moeAppId)
|
|
311
|
-
|
|
312
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
313
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
314
|
-
MoERNiOS.setUserAttribute(payload);
|
|
315
|
-
}
|
|
273
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
316
274
|
},
|
|
317
275
|
|
|
318
276
|
/**
|
|
@@ -320,31 +278,19 @@ var ReactMoE = {
|
|
|
320
278
|
* @param birthday birthday to be set in ISO format [yyyy-MM-dd'T'HH:mm:ss'Z'].
|
|
321
279
|
*/
|
|
322
280
|
setUserBirthday: function (birthday: string) {
|
|
323
|
-
commonValidationCheck();
|
|
324
281
|
MoEngageLogger.verbose("Will set birthday: ", birthday);
|
|
325
282
|
const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_BDAY, birthday, TIMESTAMP, moeAppId);
|
|
326
|
-
|
|
327
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
328
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
329
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
330
|
-
MoERNiOS.setUserAttribute(payload);
|
|
331
|
-
}
|
|
283
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
332
284
|
},
|
|
333
285
|
|
|
334
286
|
/**
|
|
335
287
|
* Sets the gender of the user.
|
|
336
288
|
* @param gender gender to be set
|
|
337
289
|
*/
|
|
338
|
-
setUserGender: function (gender:
|
|
339
|
-
commonValidationCheck();
|
|
290
|
+
setUserGender: function (gender: string) {
|
|
340
291
|
MoEngageLogger.verbose("Will set gender: ", gender);
|
|
341
292
|
const payload = getUserAttributeJson(USER_ATTRIBUTE_USER_GENDER, gender, GENERAL, moeAppId);
|
|
342
|
-
|
|
343
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
344
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
345
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
346
|
-
MoERNiOS.setUserAttribute(payload);
|
|
347
|
-
}
|
|
293
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
348
294
|
},
|
|
349
295
|
|
|
350
296
|
/**
|
|
@@ -352,18 +298,12 @@ var ReactMoE = {
|
|
|
352
298
|
* @param location coordinates of the user, which should be of type MoEUserLocation
|
|
353
299
|
*/
|
|
354
300
|
setUserLocation: function (location: MoEGeoLocation) {
|
|
355
|
-
commonValidationCheck();
|
|
356
301
|
if (!(location instanceof MoEGeoLocation)) {
|
|
357
302
|
MoEngageLogger.warn("setUserLocation: location must of type MoEGeoLocation");
|
|
358
303
|
return;
|
|
359
304
|
}
|
|
360
305
|
const payload = getUserLocAttributeJson(USER_ATTRIBUTE_USER_LOCATION, location.latitude, location.longitude, moeAppId);
|
|
361
|
-
|
|
362
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
363
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
364
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
365
|
-
MoERNiOS.setUserAttribute(payload);
|
|
366
|
-
}
|
|
306
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
367
307
|
},
|
|
368
308
|
|
|
369
309
|
/**
|
|
@@ -372,7 +312,6 @@ var ReactMoE = {
|
|
|
372
312
|
* @param userAttributeValue attribute value
|
|
373
313
|
*/
|
|
374
314
|
setUserAttribute: function (userAttributeName: string, userAttributeValue: String | Number | Boolean | Array<String> | Array<Number>) {
|
|
375
|
-
commonValidationCheck();
|
|
376
315
|
MoEngageLogger.verbose(
|
|
377
316
|
"Will track user attribute [attributeName]: " +
|
|
378
317
|
userAttributeName +
|
|
@@ -380,12 +319,7 @@ var ReactMoE = {
|
|
|
380
319
|
userAttributeValue
|
|
381
320
|
);
|
|
382
321
|
const payload = getUserAttributeJson(userAttributeName, userAttributeValue, GENERAL, moeAppId);
|
|
383
|
-
|
|
384
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
385
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
386
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
387
|
-
MoERNiOS.setUserAttribute(payload);
|
|
388
|
-
}
|
|
322
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
389
323
|
},
|
|
390
324
|
|
|
391
325
|
/**
|
|
@@ -397,14 +331,8 @@ var ReactMoE = {
|
|
|
397
331
|
attributeName: String,
|
|
398
332
|
date: String
|
|
399
333
|
) {
|
|
400
|
-
commonValidationCheck();
|
|
401
334
|
const payload = getUserAttributeJson(attributeName, date, TIMESTAMP, moeAppId);
|
|
402
|
-
|
|
403
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
404
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
405
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
406
|
-
MoERNiOS.setUserAttribute(payload);
|
|
407
|
-
}
|
|
335
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
408
336
|
},
|
|
409
337
|
|
|
410
338
|
/**
|
|
@@ -416,70 +344,46 @@ var ReactMoE = {
|
|
|
416
344
|
userAttributeName: string,
|
|
417
345
|
location: MoEGeoLocation
|
|
418
346
|
) {
|
|
419
|
-
commonValidationCheck();
|
|
420
347
|
if (!(location instanceof MoEGeoLocation)) {
|
|
421
348
|
MoEngageLogger.warn("setUserAttributeWithLocation: location must of type MoEGeoLocation");
|
|
422
349
|
return;
|
|
423
350
|
}
|
|
424
351
|
const payload = getUserLocAttributeJson(userAttributeName, location.latitude, location.longitude, moeAppId);
|
|
425
|
-
|
|
426
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
427
|
-
MoERNAndroid.setUserAttribute(payload);
|
|
428
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
429
|
-
MoERNiOS.setUserAttribute(payload);
|
|
430
|
-
}
|
|
352
|
+
MoEReactBridge.setUserAttribute(payload);
|
|
431
353
|
},
|
|
432
354
|
|
|
433
355
|
/**
|
|
434
356
|
* Notifys the SDK that the user has logged out of the app.
|
|
435
357
|
*/
|
|
436
358
|
logout: function () {
|
|
437
|
-
commonValidationCheck();
|
|
438
359
|
MoEngageLogger.verbose("Will logout user");
|
|
439
|
-
|
|
440
|
-
MoERNAndroid.logout(getAppIdJson(moeAppId));
|
|
441
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
442
|
-
MoERNiOS.logout(getAppIdJson(moeAppId));
|
|
443
|
-
}
|
|
360
|
+
MoEReactBridge.logout(getAppIdJson(moeAppId));
|
|
444
361
|
},
|
|
445
362
|
|
|
446
363
|
/**
|
|
447
364
|
* Call this method wherever InApp message has to be shown, if available
|
|
448
365
|
*/
|
|
449
366
|
showInApp: function () {
|
|
450
|
-
commonValidationCheck();
|
|
451
367
|
MoEngageLogger.verbose("Will try to show in-app.");
|
|
452
|
-
|
|
453
|
-
MoERNAndroid.showInApp(getAppIdJson(moeAppId));
|
|
454
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
455
|
-
MoERNiOS.showInApp(getAppIdJson(moeAppId));
|
|
456
|
-
}
|
|
368
|
+
MoEReactBridge.showInApp(getAppIdJson(moeAppId));
|
|
457
369
|
},
|
|
458
370
|
|
|
459
371
|
/**
|
|
460
|
-
* Call
|
|
372
|
+
* Call This method to show the nudge
|
|
373
|
+
* @param position position at which nudge should be displayed.
|
|
461
374
|
*/
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
467
|
-
MoERNiOS.getSelfHandledInApp(getAppIdJson(moeAppId));
|
|
468
|
-
}
|
|
375
|
+
showNudge: function (position: MoEngageNudgePosition = MoEngageNudgePosition.Any) {
|
|
376
|
+
MoEngageLogger.verbose("Will try to show nudge");
|
|
377
|
+
let payload = getNudgeDisplayJson(position, moeAppId);
|
|
378
|
+
MoEReactBridge.showNudge(payload);
|
|
469
379
|
},
|
|
470
380
|
|
|
471
381
|
/**
|
|
472
|
-
* Call
|
|
473
|
-
* @param position position at which nudge should be displayed.
|
|
382
|
+
* Call this method to get the campaign info for self handled inApps
|
|
474
383
|
*/
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
479
|
-
MoERNAndroid.showNudge(jsonPayload);
|
|
480
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
481
|
-
MoERNiOS.showNudge(jsonPayload);
|
|
482
|
-
}
|
|
384
|
+
getSelfHandledInApp: function () {
|
|
385
|
+
MoEngageLogger.verbose("Will try to fetch self handled inapp");
|
|
386
|
+
MoEReactBridge.getSelfHandledInApp(getAppIdJson(moeAppId));
|
|
483
387
|
},
|
|
484
388
|
|
|
485
389
|
/**
|
|
@@ -487,17 +391,12 @@ var ReactMoE = {
|
|
|
487
391
|
* @param {MoESelfHandledCampaignData}campInfo : campaign information object
|
|
488
392
|
*/
|
|
489
393
|
selfHandledShown: function (inAppCampaign: MoESelfHandledCampaignData) {
|
|
490
|
-
commonValidationCheck();
|
|
491
394
|
if (!(inAppCampaign instanceof MoESelfHandledCampaignData)) {
|
|
492
395
|
MoEngageLogger.warn("selfHandledShown: inAppCampaign must of MoESelfHandledCampaignData type");
|
|
493
396
|
return;
|
|
494
397
|
}
|
|
495
398
|
let campaignJson = getSelfHandledJson(inAppCampaign, "impression", moeAppId);
|
|
496
|
-
|
|
497
|
-
MoERNAndroid.selfHandledShown(campaignJson);
|
|
498
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
499
|
-
MoERNiOS.selfHandledShown(campaignJson);
|
|
500
|
-
}
|
|
399
|
+
MoEReactBridge.updateSelfHandledInAppStatus(campaignJson);
|
|
501
400
|
},
|
|
502
401
|
|
|
503
402
|
/**
|
|
@@ -505,17 +404,12 @@ var ReactMoE = {
|
|
|
505
404
|
* @param {MoESelfHandledCampaignData}campInfo : campaign information object
|
|
506
405
|
*/
|
|
507
406
|
selfHandledClicked: function (moEClickData: MoESelfHandledCampaignData) {
|
|
508
|
-
commonValidationCheck();
|
|
509
407
|
if (!(moEClickData instanceof MoESelfHandledCampaignData)) {
|
|
510
408
|
MoEngageLogger.warn("selfHandledClicked: inAppCampaign must of MoEClickData type");
|
|
511
409
|
return;
|
|
512
410
|
}
|
|
513
411
|
let campaignJson = getSelfHandledJson(moEClickData, "click", moeAppId);
|
|
514
|
-
|
|
515
|
-
MoERNAndroid.selfHandledClicked(campaignJson);
|
|
516
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
517
|
-
MoERNiOS.selfHandledClicked(campaignJson);
|
|
518
|
-
}
|
|
412
|
+
MoEReactBridge.updateSelfHandledInAppStatus(campaignJson);
|
|
519
413
|
},
|
|
520
414
|
|
|
521
415
|
/**
|
|
@@ -523,17 +417,12 @@ var ReactMoE = {
|
|
|
523
417
|
* @param {MoESelfHandledCampaignData}campInfo : campaign information object
|
|
524
418
|
*/
|
|
525
419
|
selfHandledDismissed: function (inAppCampaign: MoESelfHandledCampaignData) {
|
|
526
|
-
commonValidationCheck();
|
|
527
420
|
if (!(inAppCampaign instanceof MoESelfHandledCampaignData)) {
|
|
528
421
|
MoEngageLogger.warn("selfHandledDismissed: inAppCampaign must of MoESelfHandledCampaignData type");
|
|
529
422
|
return;
|
|
530
423
|
}
|
|
531
424
|
let campaignJson = getSelfHandledJson(inAppCampaign, "dismissed", moeAppId);
|
|
532
|
-
|
|
533
|
-
MoERNAndroid.selfHandledDismissed(campaignJson);
|
|
534
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
535
|
-
MoERNiOS.selfHandledDismissed(campaignJson);
|
|
536
|
-
}
|
|
425
|
+
MoEReactBridge.updateSelfHandledInAppStatus(campaignJson);
|
|
537
426
|
},
|
|
538
427
|
|
|
539
428
|
/**
|
|
@@ -541,29 +430,19 @@ var ReactMoE = {
|
|
|
541
430
|
* @param {Array{String}}contexts : Name of all the contexts
|
|
542
431
|
*/
|
|
543
432
|
setCurrentContext: function (contexts: Array<String>) {
|
|
544
|
-
commonValidationCheck();
|
|
545
433
|
if (!MoEHelper.validateArrayOfString(contexts)) {
|
|
546
434
|
MoEngageLogger.warn("setCurrentContext: contexts must be a non empty array of strings");
|
|
547
435
|
return;
|
|
548
436
|
}
|
|
549
437
|
let payload = getInAppContextJson(contexts, moeAppId);
|
|
550
|
-
|
|
551
|
-
MoERNAndroid.setAppContext(payload);
|
|
552
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
553
|
-
MoERNiOS.setAppContext(payload);
|
|
554
|
-
}
|
|
438
|
+
MoEReactBridge.setAppContext(payload);
|
|
555
439
|
},
|
|
556
440
|
|
|
557
441
|
/**
|
|
558
442
|
* Call this method to the reset current context for inApp module.
|
|
559
443
|
*/
|
|
560
444
|
resetCurrentContext: function () {
|
|
561
|
-
|
|
562
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
563
|
-
MoERNAndroid.resetAppContext(getAppIdJson(moeAppId));
|
|
564
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
565
|
-
MoERNiOS.resetAppContext(getAppIdJson(moeAppId));
|
|
566
|
-
}
|
|
445
|
+
MoEReactBridge.resetAppContext(getAppIdJson(moeAppId));
|
|
567
446
|
},
|
|
568
447
|
|
|
569
448
|
/**
|
|
@@ -573,12 +452,10 @@ var ReactMoE = {
|
|
|
573
452
|
* @param {String} pushToken
|
|
574
453
|
*/
|
|
575
454
|
passFcmPushToken: function (pushToken: string) {
|
|
576
|
-
commonValidationCheck();
|
|
577
455
|
MoEngageLogger.verbose("Will process push token");
|
|
578
|
-
let payload = getMoEPushTokenJson(pushToken, PUSH_SERVICE_FCM, PLATFORM_ANDROID, moeAppId);
|
|
579
|
-
|
|
580
456
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
581
|
-
|
|
457
|
+
let payload = getMoEPushTokenJson(pushToken, PUSH_SERVICE_FCM, PLATFORM_ANDROID, moeAppId);
|
|
458
|
+
MoEReactBridge.passFcmPushToken(payload);
|
|
582
459
|
} else {
|
|
583
460
|
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
584
461
|
}
|
|
@@ -590,12 +467,10 @@ var ReactMoE = {
|
|
|
590
467
|
* @param {JSONObject} pushPayload
|
|
591
468
|
*/
|
|
592
469
|
passFcmPushPayload: function (pushPayload: object) {
|
|
593
|
-
commonValidationCheck();
|
|
594
470
|
MoEngageLogger.verbose("Will process push payload.");
|
|
595
|
-
let payload = getMoEPushCampaignJson(pushPayload, PUSH_SERVICE_FCM, moeAppId);
|
|
596
|
-
|
|
597
471
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
598
|
-
|
|
472
|
+
let payload = getMoEPushCampaignJson(pushPayload, PUSH_SERVICE_FCM, moeAppId);
|
|
473
|
+
MoEReactBridge.passFcmPushPayload(payload);
|
|
599
474
|
} else {
|
|
600
475
|
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
601
476
|
}
|
|
@@ -603,49 +478,40 @@ var ReactMoE = {
|
|
|
603
478
|
|
|
604
479
|
/**
|
|
605
480
|
* Call this method to register for push notification in iOS
|
|
481
|
+
* Note: This API is only for iOS platform and is a no-operation method for other plaforms.
|
|
606
482
|
*/
|
|
607
483
|
registerForPush: function () {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
MoERNiOS.registerForPush();
|
|
484
|
+
if (Platform.OS == PLATFORM_IOS) {
|
|
485
|
+
MoEngageLogger.verbose("Will registerForPush");
|
|
486
|
+
MoEReactBridge.registerForPush();
|
|
487
|
+
} else {
|
|
488
|
+
MoEngageLogger.debug("This api is not supported on Android platform.");
|
|
614
489
|
}
|
|
615
490
|
},
|
|
616
491
|
|
|
617
492
|
/**
|
|
618
|
-
* Call this method to
|
|
493
|
+
* Call this method to enable the data tracking
|
|
494
|
+
*
|
|
495
|
+
* Note: By default data tracking is enabled.
|
|
496
|
+
*
|
|
497
|
+
* @since 10.0.0
|
|
619
498
|
*/
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
MoEngageLogger.debug("This api is not supported on android platform.");
|
|
625
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
626
|
-
MoERNiOS.disableInbox(getAppIdJson(moeAppId));
|
|
627
|
-
}
|
|
499
|
+
enableDataTracking: function () {
|
|
500
|
+
MoEngageLogger.verbose("Will opt in data tracking");
|
|
501
|
+
let payload = getOptOutTrackingJson("data", false, moeAppId);
|
|
502
|
+
MoEReactBridge.optOutDataTracking(payload);
|
|
628
503
|
},
|
|
629
504
|
|
|
630
505
|
/**
|
|
631
|
-
* Call this method to
|
|
506
|
+
* Call this method to disable the data tracking
|
|
507
|
+
* Note: When data tracking is opted out no custom event or user attribute is tracked on MoEngage Platform.
|
|
508
|
+
*
|
|
509
|
+
* @since 10.0.0
|
|
632
510
|
*/
|
|
633
|
-
|
|
634
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
635
|
-
//Android code
|
|
636
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
637
|
-
MoERNiOS.startGeofenceMonitoring(getAppIdJson(moeAppId));
|
|
638
|
-
}
|
|
639
|
-
},
|
|
640
|
-
|
|
641
|
-
optOutDataTracking: function (shouldOptOutDataTracking: boolean) {
|
|
511
|
+
disableDataTracking: function () {
|
|
642
512
|
MoEngageLogger.verbose("Will opt out data tracking");
|
|
643
|
-
let payload = getOptOutTrackingJson("data",
|
|
644
|
-
|
|
645
|
-
MoERNAndroid.optOutDataTracking(payload);
|
|
646
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
647
|
-
MoERNiOS.optOutDataTracking(payload);
|
|
648
|
-
}
|
|
513
|
+
let payload = getOptOutTrackingJson("data", true, moeAppId);
|
|
514
|
+
MoEReactBridge.optOutDataTracking(payload);
|
|
649
515
|
},
|
|
650
516
|
|
|
651
517
|
/**
|
|
@@ -655,54 +521,56 @@ var ReactMoE = {
|
|
|
655
521
|
* @param {String} pushToken
|
|
656
522
|
*/
|
|
657
523
|
passPushKitPushToken: function (pushToken: string) {
|
|
658
|
-
commonValidationCheck();
|
|
659
524
|
MoEngageLogger.verbose("Will process push-kit push token");
|
|
660
|
-
let payload = getMoEPushTokenJson(pushToken, PUSH_SERVICE_PUSH_KIT, PLATFORM_ANDROID, moeAppId);
|
|
661
|
-
|
|
662
525
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
663
|
-
|
|
526
|
+
let payload = getMoEPushTokenJson(pushToken, PUSH_SERVICE_PUSH_KIT, PLATFORM_ANDROID, moeAppId);
|
|
527
|
+
MoEReactBridge.passPushKitPushToken(payload);
|
|
664
528
|
} else {
|
|
665
529
|
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
666
530
|
}
|
|
667
531
|
},
|
|
668
532
|
|
|
533
|
+
/**
|
|
534
|
+
* API to enable all features of the SDK for the account configured as default.
|
|
535
|
+
* Note: All the feature is enabled by default.
|
|
536
|
+
*/
|
|
669
537
|
enableSdk: function () {
|
|
670
538
|
MoEngageLogger.verbose("Will enable SDK");
|
|
671
539
|
let payload = getSdkStateJson(true, moeAppId);
|
|
672
|
-
|
|
673
|
-
MoERNAndroid.updateSdkState(payload);
|
|
674
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
675
|
-
MoERNiOS.updateSdkState(payload);
|
|
676
|
-
}
|
|
540
|
+
MoEReactBridge.updateSdkState(payload);
|
|
677
541
|
},
|
|
678
542
|
|
|
543
|
+
/**
|
|
544
|
+
* API to disable all features of the SDK for the account configured as default.
|
|
545
|
+
*/
|
|
679
546
|
disableSdk: function () {
|
|
680
547
|
MoEngageLogger.verbose("Will disable SDK");
|
|
681
548
|
let payload = getSdkStateJson(false, moeAppId);
|
|
682
|
-
|
|
683
|
-
if (Platform.OS == PLATFORM_ANDROID) {
|
|
684
|
-
MoERNAndroid.updateSdkState(payload);
|
|
685
|
-
} else if (Platform.OS == PLATFORM_IOS) {
|
|
686
|
-
MoERNiOS.updateSdkState(payload);
|
|
687
|
-
}
|
|
549
|
+
MoEReactBridge.updateSdkState(payload);
|
|
688
550
|
},
|
|
689
551
|
|
|
552
|
+
/**
|
|
553
|
+
* Notify the MoEngage SDK about the device orientation change
|
|
554
|
+
* Note: This API is only for Android platform and is a no-operation method for other plaforms.
|
|
555
|
+
*/
|
|
690
556
|
onOrientationChanged: function () {
|
|
691
557
|
MoEngageLogger.verbose("Will process screen rotation.");
|
|
692
558
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
693
|
-
|
|
559
|
+
MoEReactBridge.onOrientationChanged();
|
|
694
560
|
}
|
|
695
561
|
},
|
|
696
562
|
|
|
697
563
|
/**
|
|
698
564
|
* API to enable Advertising Id tracking for Android.
|
|
565
|
+
* Note: This API is only for Android platform and is a no-operation method for other plaforms.
|
|
699
566
|
*/
|
|
700
567
|
enableAdIdTracking: function () {
|
|
701
568
|
MoEngageLogger.verbose("Will enable advertising-id tracking");
|
|
702
|
-
let payload = getAdIdTrackingJson(true, moeAppId);
|
|
703
|
-
|
|
704
569
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
705
|
-
|
|
570
|
+
let payload = getAdIdTrackingJson(true, moeAppId);
|
|
571
|
+
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(payload);
|
|
572
|
+
} else {
|
|
573
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
706
574
|
}
|
|
707
575
|
},
|
|
708
576
|
|
|
@@ -711,25 +579,30 @@ var ReactMoE = {
|
|
|
711
579
|
*
|
|
712
580
|
* By default Advertising Id tracking is disabled, call this method only if you have enabled
|
|
713
581
|
* Advertising Id tracking at some point.
|
|
582
|
+
*
|
|
583
|
+
* Note: This API is only for Android platform and is a no-operation method for other plaforms.
|
|
714
584
|
*/
|
|
715
585
|
disableAdIdTracking: function () {
|
|
716
586
|
MoEngageLogger.verbose("Will disable advertising-id tracking");
|
|
717
|
-
let payload = getAdIdTrackingJson(false, moeAppId);
|
|
718
|
-
|
|
719
587
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
720
|
-
|
|
588
|
+
let payload = getAdIdTrackingJson(false, moeAppId);
|
|
589
|
+
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(payload);
|
|
590
|
+
} else {
|
|
591
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
721
592
|
}
|
|
722
593
|
},
|
|
723
594
|
|
|
724
595
|
/**
|
|
725
596
|
* API to enable Android Id tracking for Android.
|
|
597
|
+
* Note: This API is only for Android platform and is a no-operation method for other plaforms.
|
|
726
598
|
*/
|
|
727
599
|
enableAndroidIdTracking: function () {
|
|
728
600
|
MoEngageLogger.verbose("Will enable android-id tracking");
|
|
729
|
-
let payload = getAndroidIdTrackingJson(true, moeAppId);
|
|
730
|
-
|
|
731
601
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
732
|
-
|
|
602
|
+
let payload = getAndroidIdTrackingJson(true, moeAppId);
|
|
603
|
+
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(payload);
|
|
604
|
+
} else {
|
|
605
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
733
606
|
}
|
|
734
607
|
},
|
|
735
608
|
|
|
@@ -738,41 +611,53 @@ var ReactMoE = {
|
|
|
738
611
|
*
|
|
739
612
|
* By default Android Id tracking is disabled, call this method only if you have enabled
|
|
740
613
|
* Advertising Id tracking at some point.
|
|
614
|
+
*
|
|
615
|
+
* Note: This API is only for Android platform and is a no-operation method for other plaforms.
|
|
741
616
|
*/
|
|
742
617
|
disableAndroidIdTracking: function () {
|
|
743
618
|
MoEngageLogger.verbose("Will disable android-id tracking");
|
|
744
|
-
let payload = getAndroidIdTrackingJson(false, moeAppId);
|
|
745
|
-
|
|
746
619
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
747
|
-
|
|
620
|
+
let payload = getAndroidIdTrackingJson(false, moeAppId);
|
|
621
|
+
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(payload);
|
|
622
|
+
} else {
|
|
623
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
748
624
|
}
|
|
749
625
|
},
|
|
750
626
|
|
|
751
627
|
pushPermissionResponseAndroid: function (isGranted: boolean) {
|
|
752
628
|
MoEngageLogger.verbose("Will track permission response");
|
|
753
629
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
754
|
-
|
|
630
|
+
let payload = getPermissionResponseJson(isGranted, MoEngagePermissionType.PUSH)
|
|
631
|
+
MoEReactBridge.pushPermissionResponseAndroid(payload);
|
|
632
|
+
} else {
|
|
633
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
755
634
|
}
|
|
756
635
|
},
|
|
757
636
|
|
|
758
637
|
setupNotificationChannelsAndroid: function () {
|
|
759
638
|
MoEngageLogger.verbose("Will setup notification");
|
|
760
639
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
761
|
-
|
|
640
|
+
MoEReactBridge.setupNotificationChannels();
|
|
641
|
+
} else {
|
|
642
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
762
643
|
}
|
|
763
644
|
},
|
|
764
645
|
|
|
765
646
|
navigateToSettingsAndroid: function () {
|
|
766
647
|
MoEngageLogger.verbose("Will navigate to settings");
|
|
767
648
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
768
|
-
|
|
649
|
+
MoEReactBridge.navigateToSettingsAndroid();
|
|
650
|
+
} else {
|
|
651
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
769
652
|
}
|
|
770
653
|
},
|
|
771
654
|
|
|
772
655
|
requestPushPermissionAndroid: function () {
|
|
773
656
|
MoEngageLogger.verbose("Will request push permission.");
|
|
774
657
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
775
|
-
|
|
658
|
+
MoEReactBridge.requestPushPermissionAndroid();
|
|
659
|
+
} else {
|
|
660
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
776
661
|
}
|
|
777
662
|
},
|
|
778
663
|
|
|
@@ -784,36 +669,41 @@ var ReactMoE = {
|
|
|
784
669
|
*/
|
|
785
670
|
updatePushPermissionRequestCountAndroid: function (count: number) {
|
|
786
671
|
MoEngageLogger.verbose("Will increment push permission request count");
|
|
787
|
-
let payload = getPushPermissionRequestCountJson(count, moeAppId);
|
|
788
|
-
|
|
789
672
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
790
|
-
|
|
673
|
+
let payload = getPushPermissionRequestCountJson(count, moeAppId);
|
|
674
|
+
MoEReactBridge.updatePushPermissionRequestCountAndroid(payload);
|
|
675
|
+
} else {
|
|
676
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
791
677
|
}
|
|
792
678
|
},
|
|
793
679
|
|
|
794
680
|
/**
|
|
795
681
|
* API to enable Device Id tracking for Android.
|
|
796
682
|
*
|
|
797
|
-
* Note: By default Device Id tracking is enabled
|
|
683
|
+
* Note: By default Device Id tracking is enabled.This API is only for Android platform and is a no-operation method for other plaforms.
|
|
798
684
|
*/
|
|
799
685
|
enableDeviceIdTracking: function () {
|
|
800
686
|
MoEngageLogger.verbose("Will enable device id tracking");
|
|
801
|
-
let payload = getDeviceIdTrackingJson(true, moeAppId);
|
|
802
|
-
|
|
803
687
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
804
|
-
|
|
688
|
+
let payload = getDeviceIdTrackingJson(true, moeAppId);
|
|
689
|
+
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(payload);
|
|
690
|
+
} else {
|
|
691
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
805
692
|
}
|
|
806
693
|
},
|
|
807
694
|
|
|
808
695
|
/**
|
|
809
696
|
* API to disable Device Id tracking for Android.
|
|
697
|
+
*
|
|
698
|
+
* Note: This API is only for Android platform and is a no-operation method for other plaforms.
|
|
810
699
|
*/
|
|
811
700
|
disableDeviceIdTracking: function () {
|
|
812
701
|
MoEngageLogger.verbose("Will disable device id tracking");
|
|
813
|
-
let payload = getDeviceIdTrackingJson(false, moeAppId);
|
|
814
|
-
|
|
815
702
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
816
|
-
|
|
703
|
+
let payload = getDeviceIdTrackingJson(false, moeAppId);
|
|
704
|
+
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(payload);
|
|
705
|
+
} else {
|
|
706
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
817
707
|
}
|
|
818
708
|
},
|
|
819
709
|
|
|
@@ -827,17 +717,19 @@ var ReactMoE = {
|
|
|
827
717
|
deleteUser: async function (): Promise<UserDeletionData> {
|
|
828
718
|
MoEngageLogger.verbose("Will delete user");
|
|
829
719
|
const accountMetaJson = getAppIdJson(moeAppId);
|
|
830
|
-
|
|
831
720
|
try {
|
|
832
721
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
833
|
-
|
|
722
|
+
const deleteUserPayload = await MoEReactBridge.deleteUser(accountMetaJson);
|
|
723
|
+
return getUserDeletionData(deleteUserPayload);
|
|
724
|
+
} else {
|
|
725
|
+
MoEngageLogger.debug("This api is not supported on iOS platform.");
|
|
834
726
|
}
|
|
835
|
-
} catch(error) {
|
|
727
|
+
} catch (error) {
|
|
836
728
|
MoEngageLogger.error(`deleteUser(): ${error}`)
|
|
837
729
|
}
|
|
838
730
|
|
|
839
731
|
return new UserDeletionData(new MoEAccountMeta(moeAppId), false)
|
|
840
|
-
}
|
|
732
|
+
},
|
|
841
733
|
};
|
|
842
734
|
|
|
843
735
|
export {
|
|
@@ -855,3 +747,4 @@ export {
|
|
|
855
747
|
MoEngageNudgePosition,
|
|
856
748
|
};
|
|
857
749
|
export default ReactMoE;
|
|
750
|
+
|