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.
- package/CHANGELOG.md +53 -1
- package/ReactNativeMoEngage.podspec +3 -3
- package/android/build.gradle +11 -12
- package/android/gradle/wrapper/gradle-wrapper.properties +3 -3
- package/android/gradle.properties +0 -1
- package/android/src/main/java/com/moengage/react/EventEmitterImpl.kt +46 -21
- package/android/src/main/java/com/moengage/react/MoEInitializer.kt +44 -13
- package/android/src/main/java/com/moengage/react/MoEReactBridge.kt +82 -85
- package/android/src/main/java/com/moengage/react/MoEReactHelper.kt +2 -2
- package/android/src/main/java/com/moengage/react/PayloadGenerator.kt +32 -17
- package/iOS/MoEReactBridge/MoEReactBridge.h +1 -1
- package/iOS/MoEReactBridge/MoEReactBridge.m +34 -60
- package/iOS/MoEReactBridge/{MOReactInitializer.h → MoEngageInitializer.h} +11 -11
- package/iOS/MoEReactBridge/MoEngageInitializer.m +153 -0
- package/iOS/MoEReactBridge/{MoEReactConstants.h → MoEngageReactConstants.h} +12 -3
- package/iOS/MoEReactBridge/{MoEReactConstants.m → MoEngageReactConstants.m} +13 -7
- package/iOS/MoEReactBridge/MoEngageReactPluginInfo.h +2 -0
- package/iOS/MoEReactBridge.xcodeproj/project.pbxproj +6 -6
- package/package.json +8 -3
- package/src/index.ts +134 -203
- package/src/models/MoEAccountMeta.ts +8 -0
- package/src/models/MoEAction.ts +4 -0
- package/src/models/MoEActionType.ts +4 -0
- package/src/models/MoECampaignContext.ts +10 -0
- package/src/models/MoECampaignData.ts +14 -0
- package/src/models/MoEClickData.ts +18 -0
- package/src/models/MoEGeoLocation.ts +2 -10
- package/src/models/MoEInAppCustomAction.ts +8 -13
- package/src/models/MoEInAppData.ts +16 -0
- package/src/models/MoEInAppNavigation.ts +14 -24
- package/src/models/MoENavigationType.ts +4 -0
- package/src/models/MoEPlatform.ts +4 -0
- package/src/models/MoEProperties.ts +19 -15
- package/src/models/MoEPushCampaign.ts +6 -22
- package/src/models/MoEPushPayload.ts +14 -0
- package/src/models/MoEPushService.ts +4 -4
- package/src/models/MoEPushToken.ts +6 -15
- package/src/models/MoESelfHandledCampaign.ts +10 -0
- package/src/models/MoESelfHandledCampaignData.ts +18 -0
- package/src/moeParser/MoEInAppParser.ts +192 -0
- package/src/moeParser/MoEPushNotificationParser.ts +78 -0
- package/src/platform/MoERNAndroid.ts +36 -92
- package/src/platform/MoERNiOS.ts +27 -60
- package/src/utils/MoEConstants.ts +59 -0
- package/src/utils/MoEEventHandlerHelper.ts +38 -25
- package/src/utils/MoEJsonBuilder.ts +220 -0
- package/src/utils/MoEObjectToJson.ts +44 -0
- package/iOS/MoEReactBridge/MOReactInitializer.m +0 -172
- package/iOS/MoEReactBridge/MOReactPluginInfo.h +0 -2
- package/src/models/MoEInAppCampaign.ts +0 -46
- package/src/models/MoEInAppSelfHandledCampaign.ts +0 -34
|
@@ -1,144 +1,100 @@
|
|
|
1
|
+
import { getAdIdTrackingJson, getAndroidIdTrackingJson, getAppIdJson, getMoEPushCampaignJson, getMoEPushTokenJson, getOptOutTrackingJson, getSdkStateJson } from "../utils/MoEJsonBuilder";
|
|
2
|
+
|
|
1
3
|
const MoEReactBridge = require("react-native").NativeModules.MoEReactBridge;
|
|
4
|
+
const PLATFORM_ANDROID = "android";
|
|
2
5
|
|
|
3
6
|
export class MoERNAndroid {
|
|
4
|
-
static initialize() {
|
|
5
|
-
MoEReactBridge.initialize();
|
|
7
|
+
static initialize(payload: { [k: string]: any }) {
|
|
8
|
+
MoEReactBridge.initialize(JSON.stringify(payload));
|
|
6
9
|
}
|
|
7
10
|
|
|
8
|
-
static trackEvent(payload:
|
|
11
|
+
static trackEvent(payload: { [k: string]: any }) {
|
|
9
12
|
MoEReactBridge.trackEvent(JSON.stringify(payload))
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
static setAppStatus(payload:
|
|
15
|
+
static setAppStatus(payload: { [k: string]: any }) {
|
|
13
16
|
MoEReactBridge.setAppStatus(JSON.stringify(payload));
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
static setUserAttribute(payload:
|
|
19
|
+
static setUserAttribute(payload: { [k: string]: any }) {
|
|
17
20
|
MoEReactBridge.setUserAttribute(JSON.stringify(payload));
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
static setAlias(payload:
|
|
23
|
+
static setAlias(payload: { [k: string]: any }) {
|
|
21
24
|
MoEReactBridge.setAlias(JSON.stringify(payload));
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
static logout() {
|
|
25
|
-
MoEReactBridge.logout();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static showInApp() {
|
|
29
|
-
MoEReactBridge.showInApp();
|
|
27
|
+
static logout(payload: { [k: string]: any }) {
|
|
28
|
+
MoEReactBridge.logout(JSON.stringify(payload));
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
static
|
|
33
|
-
MoEReactBridge.
|
|
31
|
+
static showInApp(payload: { [k: string]: any }) {
|
|
32
|
+
MoEReactBridge.showInApp(JSON.stringify(payload));
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
static
|
|
37
|
-
payload
|
|
38
|
-
MoERNAndroid.selfHandledCallback(payload);
|
|
35
|
+
static getSelfHandledInApp(payload: { [k: string]: any }) {
|
|
36
|
+
MoEReactBridge.getSelfHandledInApp(JSON.stringify(payload));
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
static
|
|
42
|
-
payload["type"] = "click";
|
|
39
|
+
static selfHandledShown(payload: { [k: string]: any }) {
|
|
43
40
|
MoERNAndroid.selfHandledCallback(payload);
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
static
|
|
47
|
-
payload["type"] = "dismissed";
|
|
43
|
+
static selfHandledClicked(payload: { [k: string]: any }) {
|
|
48
44
|
MoERNAndroid.selfHandledCallback(payload);
|
|
49
45
|
}
|
|
50
46
|
|
|
51
|
-
static
|
|
52
|
-
payload["type"] = "primary_clicked";
|
|
47
|
+
static selfHandledDismissed(payload: { [k: string]: any }) {
|
|
53
48
|
MoERNAndroid.selfHandledCallback(payload);
|
|
54
49
|
}
|
|
55
50
|
|
|
56
|
-
private static selfHandledCallback(payload:
|
|
51
|
+
private static selfHandledCallback(payload: { [k: string]: any }) {
|
|
57
52
|
MoEReactBridge.selfHandledCallback(JSON.stringify(payload));
|
|
58
53
|
}
|
|
59
54
|
|
|
60
|
-
static setAppContext(payload:
|
|
55
|
+
static setAppContext(payload: { [k: string]: any }) {
|
|
61
56
|
MoEReactBridge.setAppContext(JSON.stringify(payload));
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
static resetAppContext() {
|
|
65
|
-
MoEReactBridge.resetAppContext();
|
|
59
|
+
static resetAppContext(payload: { [k: string]: any }) {
|
|
60
|
+
MoEReactBridge.resetAppContext(JSON.stringify(payload));
|
|
66
61
|
}
|
|
67
62
|
|
|
68
|
-
static passFcmPushToken(
|
|
69
|
-
let payload = {
|
|
70
|
-
token: pushToken,
|
|
71
|
-
service: PUSH_SERVICE_FCM
|
|
72
|
-
};
|
|
63
|
+
static passFcmPushToken(payload: { [k: string]: any }) {
|
|
73
64
|
MoERNAndroid.passPushToken(payload)
|
|
74
65
|
}
|
|
75
66
|
|
|
76
|
-
static passFcmPushPayload(pushPayload:
|
|
77
|
-
|
|
78
|
-
payload: pushPayload,
|
|
79
|
-
service: PUSH_SERVICE_FCM
|
|
80
|
-
};
|
|
81
|
-
MoERNAndroid.passPushPayload(payload)
|
|
67
|
+
static passFcmPushPayload(pushPayload: { [k: string]: any }) {
|
|
68
|
+
MoERNAndroid.passPushPayload(pushPayload)
|
|
82
69
|
}
|
|
83
70
|
|
|
84
|
-
private static passPushToken(payload:
|
|
71
|
+
private static passPushToken(payload: { [k: string]: any }) {
|
|
85
72
|
MoEReactBridge.passPushToken(JSON.stringify(payload));
|
|
86
73
|
}
|
|
87
74
|
|
|
88
|
-
private static passPushPayload(payload:
|
|
75
|
+
private static passPushPayload(payload: { [k: string]: any }) {
|
|
89
76
|
MoEReactBridge.passPushPayload(JSON.stringify(payload));
|
|
90
77
|
}
|
|
91
78
|
|
|
92
|
-
static
|
|
93
|
-
MoEReactBridge.enableLogs();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
static optOutDataTracking(shouldOptOutDataTracking: boolean){
|
|
97
|
-
let payload = {
|
|
98
|
-
type: "data",
|
|
99
|
-
state: shouldOptOutDataTracking
|
|
100
|
-
};
|
|
101
|
-
MoERNAndroid.optOutTracking(payload)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
static optOutPushNotification(shouldOptOutPushNotification: boolean){
|
|
105
|
-
let payload = {
|
|
106
|
-
type: "push",
|
|
107
|
-
state: shouldOptOutPushNotification
|
|
108
|
-
};
|
|
109
|
-
MoERNAndroid.optOutTracking(payload)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
static optOutInAppNotification(shouldOptOutInApp: boolean){
|
|
113
|
-
let payload = {
|
|
114
|
-
type: "inapp",
|
|
115
|
-
state: shouldOptOutInApp
|
|
116
|
-
};
|
|
79
|
+
static optOutDataTracking(payload: { [k: string]: any }) {
|
|
117
80
|
MoERNAndroid.optOutTracking(payload)
|
|
118
81
|
}
|
|
119
82
|
|
|
120
|
-
private static optOutTracking(payload:
|
|
83
|
+
private static optOutTracking(payload: { [k: string]: any }) {
|
|
121
84
|
MoEReactBridge.optOutTracking(JSON.stringify(payload));
|
|
122
85
|
}
|
|
123
86
|
|
|
124
|
-
static validateSDKVersion(){
|
|
87
|
+
static validateSDKVersion() {
|
|
125
88
|
MoEReactBridge.validateSdkVersion().catch((error: Error) => {
|
|
126
89
|
console.error(error.message);
|
|
127
90
|
});
|
|
128
91
|
}
|
|
129
92
|
|
|
130
|
-
static passPushKitPushToken(
|
|
131
|
-
let payload = {
|
|
132
|
-
token: pushToken,
|
|
133
|
-
service: PUSH_SERVICE_PUSH_KIT
|
|
134
|
-
};
|
|
93
|
+
static passPushKitPushToken(payload: { [k: string]: any }) {
|
|
135
94
|
MoERNAndroid.passPushToken(payload)
|
|
136
95
|
}
|
|
137
96
|
|
|
138
|
-
static updateSdkState(
|
|
139
|
-
let payload = {
|
|
140
|
-
isSdkEnabled: state
|
|
141
|
-
};
|
|
97
|
+
static updateSdkState(payload: { [k: string]: any }) {
|
|
142
98
|
MoEReactBridge.updateSdkState(JSON.stringify(payload));
|
|
143
99
|
}
|
|
144
100
|
|
|
@@ -146,31 +102,19 @@ export class MoERNAndroid {
|
|
|
146
102
|
MoEReactBridge.onOrientationChanged()
|
|
147
103
|
}
|
|
148
104
|
|
|
149
|
-
static enableAdIdTracking() {
|
|
150
|
-
let payload = {
|
|
151
|
-
"isAdIdTrackingEnabled": true
|
|
152
|
-
}
|
|
105
|
+
static enableAdIdTracking(payload: { [k: string]: any }) {
|
|
153
106
|
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(JSON.stringify(payload))
|
|
154
107
|
}
|
|
155
108
|
|
|
156
|
-
static disableAdIdTracking() {
|
|
157
|
-
let payload = {
|
|
158
|
-
"isAdIdTrackingEnabled": false
|
|
159
|
-
}
|
|
109
|
+
static disableAdIdTracking(payload: { [k: string]: any }) {
|
|
160
110
|
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(JSON.stringify(payload))
|
|
161
111
|
}
|
|
162
112
|
|
|
163
|
-
static enableAndroidIdTracking() {
|
|
164
|
-
let payload = {
|
|
165
|
-
"isAndroidIdTrackingEnabled": true
|
|
166
|
-
}
|
|
113
|
+
static enableAndroidIdTracking(payload: { [k: string]: any }) {
|
|
167
114
|
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(JSON.stringify(payload))
|
|
168
115
|
}
|
|
169
116
|
|
|
170
|
-
static disableAndroidIdTracking() {
|
|
171
|
-
let payload = {
|
|
172
|
-
"isAndroidIdTrackingEnabled": false
|
|
173
|
-
}
|
|
117
|
+
static disableAndroidIdTracking(payload: { [k: string]: any }) {
|
|
174
118
|
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(JSON.stringify(payload))
|
|
175
119
|
}
|
|
176
120
|
}
|
package/src/platform/MoERNiOS.ts
CHANGED
|
@@ -1,76 +1,66 @@
|
|
|
1
|
+
import { getAppIdJson, getOptOutTrackingJson } from "../utils/MoEJsonBuilder";
|
|
2
|
+
|
|
1
3
|
const MoEReactBridge = require("react-native").NativeModules.MoEReactBridge;
|
|
2
4
|
|
|
3
5
|
export class MoERNiOS {
|
|
4
|
-
static initialize() {
|
|
5
|
-
MoEReactBridge.initialize();
|
|
6
|
+
static initialize(payload: { [k: string]: any }) {
|
|
7
|
+
MoEReactBridge.initialize(payload);
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
static setAppStatus(payload:
|
|
10
|
+
static setAppStatus(payload: { [k: string]: any }) {
|
|
9
11
|
MoEReactBridge.setAppStatus(payload);
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
static trackEvent(payload:
|
|
14
|
+
static trackEvent(payload: { [k: string]: any }) {
|
|
13
15
|
MoEReactBridge.trackEventWithProperties(payload);
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
static setUserAttribute(payload:
|
|
18
|
+
static setUserAttribute(payload: { [k: string]: any }) {
|
|
17
19
|
MoEReactBridge.setUserAttribute(payload);
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
static setAlias(payload:
|
|
22
|
+
static setAlias(payload: { [k: string]: any }) {
|
|
21
23
|
MoEReactBridge.setAlias(payload);
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
static logout() {
|
|
25
|
-
MoEReactBridge.logout();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static showInApp() {
|
|
29
|
-
MoEReactBridge.showInApp();
|
|
26
|
+
static logout(payload: { [k: string]: any }) {
|
|
27
|
+
MoEReactBridge.logout(payload);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
static
|
|
33
|
-
MoEReactBridge.
|
|
30
|
+
static showInApp(payload: { [k: string]: any }) {
|
|
31
|
+
MoEReactBridge.showInApp(payload);
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
static
|
|
37
|
-
payload
|
|
38
|
-
MoEReactBridge.updateSelfHandledInAppStatusWithPayload(payload);
|
|
34
|
+
static getSelfHandledInApp(payload: { [k: string]: any }) {
|
|
35
|
+
MoEReactBridge.getSelfHandledInApp(payload);
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
static
|
|
42
|
-
payload["type"] = "primary_clicked";
|
|
38
|
+
static selfHandledShown(payload: { [k: string]: any }) {
|
|
43
39
|
MoEReactBridge.updateSelfHandledInAppStatusWithPayload(payload);
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
static selfHandledClicked(payload:
|
|
47
|
-
payload["type"] = "click";
|
|
42
|
+
static selfHandledClicked(payload: { [k: string]: any }) {
|
|
48
43
|
MoEReactBridge.updateSelfHandledInAppStatusWithPayload(payload);
|
|
49
44
|
}
|
|
50
45
|
|
|
51
|
-
static selfHandledDismissed(payload:
|
|
52
|
-
payload["type"] = "dismissed";
|
|
46
|
+
static selfHandledDismissed(payload: { [k: string]: any }) {
|
|
53
47
|
MoEReactBridge.updateSelfHandledInAppStatusWithPayload(payload);
|
|
54
48
|
}
|
|
55
49
|
|
|
56
|
-
static setAppContext(payload:
|
|
50
|
+
static setAppContext(payload: { [k: string]: any }) {
|
|
57
51
|
MoEReactBridge.setAppContext(payload);
|
|
58
52
|
}
|
|
59
53
|
|
|
60
|
-
static resetAppContext() {
|
|
61
|
-
MoEReactBridge.resetAppContext();
|
|
54
|
+
static resetAppContext(payload: { [k: string]: any }) {
|
|
55
|
+
MoEReactBridge.resetAppContext(payload);
|
|
62
56
|
}
|
|
63
57
|
|
|
64
58
|
static registerForPush() {
|
|
65
59
|
MoEReactBridge.registerForPushNotification();
|
|
66
60
|
}
|
|
67
61
|
|
|
68
|
-
static disableInbox() {
|
|
69
|
-
MoEReactBridge.disableInbox();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
static enableSDKLogs() {
|
|
73
|
-
MoEReactBridge.enableSDKLogs();
|
|
62
|
+
static disableInbox(payload: { [k: string]: any }) {
|
|
63
|
+
MoEReactBridge.disableInbox(payload);
|
|
74
64
|
}
|
|
75
65
|
|
|
76
66
|
static validateSDKVersion() {
|
|
@@ -79,42 +69,19 @@ export class MoERNiOS {
|
|
|
79
69
|
});
|
|
80
70
|
}
|
|
81
71
|
|
|
82
|
-
static startGeofenceMonitoring() {
|
|
83
|
-
MoEReactBridge.startGeofenceMonitoring();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static optOutDataTracking(shouldOptOutDataTracking: boolean){
|
|
87
|
-
let payload = {
|
|
88
|
-
type: "data",
|
|
89
|
-
state: shouldOptOutDataTracking
|
|
90
|
-
};
|
|
91
|
-
MoERNiOS.optOutTracking(payload)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
static optOutPushNotification(shouldOptOutPushNotification: boolean){
|
|
95
|
-
let payload = {
|
|
96
|
-
type: "push",
|
|
97
|
-
state: shouldOptOutPushNotification
|
|
98
|
-
};
|
|
99
|
-
MoERNiOS.optOutTracking(payload)
|
|
72
|
+
static startGeofenceMonitoring(payload: { [k: string]: any }) {
|
|
73
|
+
MoEReactBridge.startGeofenceMonitoring(payload);
|
|
100
74
|
}
|
|
101
75
|
|
|
102
|
-
static
|
|
103
|
-
let payload = {
|
|
104
|
-
type: "inapp",
|
|
105
|
-
state: shouldOptOutInApp
|
|
106
|
-
};
|
|
76
|
+
static optOutDataTracking(payload: { [k: string]: any }){
|
|
107
77
|
MoERNiOS.optOutTracking(payload)
|
|
108
78
|
}
|
|
109
79
|
|
|
110
|
-
private static optOutTracking(payload:
|
|
80
|
+
private static optOutTracking(payload: { [k: string]: any }){
|
|
111
81
|
MoEReactBridge.optOutTracking(payload);
|
|
112
82
|
}
|
|
113
83
|
|
|
114
|
-
static updateSdkState(
|
|
115
|
-
let payload = {
|
|
116
|
-
isSdkEnabled: state
|
|
117
|
-
};
|
|
84
|
+
static updateSdkState(payload: { [k: string]: any }) {
|
|
118
85
|
MoEReactBridge.updateSDKState(payload);
|
|
119
86
|
}
|
|
120
87
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const MOE_PLATFORM = 'platform'
|
|
2
|
+
export const MOE_PAYLOAD = 'payload'
|
|
3
|
+
export const MOE_DATA = 'data'
|
|
4
|
+
export const ACCOUNT_META = 'accountMeta'
|
|
5
|
+
export const APP_ID = 'appId'
|
|
6
|
+
|
|
7
|
+
//LOCATION ATTRIBUTE
|
|
8
|
+
export const MOE_LOCATION = 'location'
|
|
9
|
+
|
|
10
|
+
//INAPP CAMPAIGN
|
|
11
|
+
export const MOE_CAMPAIGN_ID = 'campaignId'
|
|
12
|
+
export const MOE_CAMPAIGN_NAME = 'campaignName'
|
|
13
|
+
export const MOE_CAMPAIGN_CONTEXT = 'campaignContext'
|
|
14
|
+
export const MOE_CUSTOM_ACTION = 'customAction'
|
|
15
|
+
export const MOE_SELF_HANDLED = 'selfHandled'
|
|
16
|
+
export const MOE_NAVIGATION = 'navigation'
|
|
17
|
+
export const MOE_WIDGET_ID = 'widgetId'
|
|
18
|
+
export const FORMATTED_CAMPAIGN_ID = 'cid'
|
|
19
|
+
export const ATTRIBUTES = 'attributes'
|
|
20
|
+
|
|
21
|
+
//IN APP CUSTOM ACTION
|
|
22
|
+
export const MOE_KEY_VALUE_PAIR = 'kvPair'
|
|
23
|
+
|
|
24
|
+
//IN APP SELF HANDLED
|
|
25
|
+
export const MOE_DISMISSINTERVAL = 'dismissInterval'
|
|
26
|
+
export const MOE_IS_CANCELLABLE = 'isCancellable'
|
|
27
|
+
|
|
28
|
+
//IN APP NAVIGATION
|
|
29
|
+
export const MOE_NAVIGATION_TYPE = 'navigationType'
|
|
30
|
+
export const ACTION_TYPE = 'actionType'
|
|
31
|
+
export const MOE_NAVIGATION_VALUE = 'value'
|
|
32
|
+
|
|
33
|
+
//PUSH TOKEN
|
|
34
|
+
export const MOE_PUSH_SERVICE = 'pushService'
|
|
35
|
+
export const MOE_TOKEN = 'token'
|
|
36
|
+
|
|
37
|
+
//PUSH CAMPAIGN
|
|
38
|
+
export const MOE_CLICKED_ACTION = 'clickedAction'
|
|
39
|
+
export const MOE_IS_DEFAULT_ACTION = 'isDefaultAction'
|
|
40
|
+
|
|
41
|
+
//INVALID OBJECT ERROR MESSAGES
|
|
42
|
+
export const MOE_IN_APP_OBJECT_ERROR = 'MoEInAppCampaign is an invalid object'
|
|
43
|
+
export const MOE_CUSTOM_ACTION_OBJ_ERROR = 'MoEInAppCustomAction is an invalid object'
|
|
44
|
+
export const MOE_SELF_HANDLED_OBJ_ERROR = 'MoEInAppSelfHandledCampaign is an invalid object'
|
|
45
|
+
export const MOE_NAVIGATION_OBJ_ERROR = 'MoEInAppNavigation is an invalid object'
|
|
46
|
+
export const MOE_PUSH_CAMPAIGN_OBJ_ERROR = 'MoEPushCampaign is an invalid object'
|
|
47
|
+
export const MOE_PUSH_TOKEN_OBJ_ERROR = 'MoEPushToken is an invalid object'
|
|
48
|
+
//USER ATTRIBUTES
|
|
49
|
+
export const USER_ATTRIBUTE_UNIQUE_ID = 'USER_ATTRIBUTE_UNIQUE_ID';
|
|
50
|
+
export const USER_ATTRIBUTE_USER_NAME = 'USER_ATTRIBUTE_USER_NAME';
|
|
51
|
+
export const USER_ATTRIBUTE_USER_FIRST_NAME = 'USER_ATTRIBUTE_USER_FIRST_NAME';
|
|
52
|
+
export const USER_ATTRIBUTE_USER_LAST_NAME = 'USER_ATTRIBUTE_USER_LAST_NAME';
|
|
53
|
+
export const USER_ATTRIBUTE_USER_EMAIL = 'USER_ATTRIBUTE_USER_EMAIL';
|
|
54
|
+
export const USER_ATTRIBUTE_USER_MOBILE = 'USER_ATTRIBUTE_USER_MOBILE';
|
|
55
|
+
export const USER_ATTRIBUTE_USER_BDAY = 'USER_ATTRIBUTE_USER_BDAY';
|
|
56
|
+
export const USER_ATTRIBUTE_USER_GENDER = 'USER_ATTRIBUTE_USER_GENDER';
|
|
57
|
+
export const USER_ATTRIBUTE_USER_LOCATION = 'USER_ATTRIBUTE_USER_LOCATION';
|
|
58
|
+
|
|
59
|
+
|
|
@@ -1,34 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const inAppEventNames: Array<String> = [
|
|
7
|
-
"inAppCampaignShown",
|
|
8
|
-
"inAppCampaignClicked",
|
|
9
|
-
"inAppCampaignDismissed",
|
|
10
|
-
"inAppCampaignCustomAction",
|
|
11
|
-
"inAppCampaignSelfHandled",
|
|
12
|
-
];
|
|
1
|
+
import { isValidObject } from "../utils/MoEHelper";
|
|
2
|
+
import { getCustomActionObj, getMoEInAppData, getNavigationObj, getMoESelfHandledCampaignData } from "../moeParser/MoEInAppParser";
|
|
3
|
+
import { getMoEPushPayload, getMoEPushToken } from "../moeParser/MoEPushNotificationParser";
|
|
4
|
+
import { MOE_DATA,ACCOUNT_META, MOE_PAYLOAD } from "./MoEConstants";
|
|
13
5
|
|
|
14
6
|
export function executeHandler(
|
|
15
7
|
handler: Function,
|
|
16
|
-
notification:
|
|
8
|
+
notification: any,
|
|
17
9
|
type: String
|
|
18
10
|
) {
|
|
19
|
-
if (handler &&
|
|
20
|
-
const payload = notification[
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
if (handler && type) {
|
|
12
|
+
const payload = notification[MOE_PAYLOAD];
|
|
13
|
+
const notificationPayload = JSON.parse(payload);
|
|
14
|
+
if (isValidObject(notificationPayload)) {
|
|
15
|
+
if (type == "pushTokenGenerated") {
|
|
16
|
+
var pushTokenObject = getMoEPushToken(notificationPayload);
|
|
17
|
+
pushTokenObject != undefined ? handler(pushTokenObject) : null;
|
|
18
|
+
}
|
|
19
|
+
else{
|
|
20
|
+
const accountMeta = notificationPayload[ACCOUNT_META];
|
|
21
|
+
if (accountMeta != undefined && isValidObject(accountMeta)) {
|
|
22
|
+
const payload = notificationPayload[MOE_DATA];
|
|
23
|
+
if (type == "inAppCampaignShown"||type == "inAppCampaignDismissed") {
|
|
24
|
+
var inAppObject = getMoEInAppData(payload,accountMeta);
|
|
25
|
+
inAppObject != undefined ? handler(inAppObject) : null;
|
|
26
|
+
}
|
|
27
|
+
else if (type == "inAppCampaignSelfHandled") {
|
|
28
|
+
var selfHandled = getMoESelfHandledCampaignData(payload,accountMeta);
|
|
29
|
+
selfHandled != undefined ? handler(selfHandled) : null;
|
|
30
|
+
}
|
|
31
|
+
else if(type == "inAppCampaignCustomAction"){
|
|
32
|
+
var cutomAction = getCustomActionObj(payload,accountMeta);
|
|
33
|
+
cutomAction != undefined ? handler(cutomAction) : null;
|
|
34
|
+
}
|
|
35
|
+
else if(type == "inAppCampaignClicked"){
|
|
36
|
+
var navigationAction = getNavigationObj(payload,accountMeta);
|
|
37
|
+
navigationAction != undefined ? handler(navigationAction) : null;
|
|
30
38
|
}
|
|
39
|
+
else if (type == "pushClicked") {
|
|
40
|
+
var pushCampaignObject = getMoEPushPayload(payload,accountMeta);
|
|
41
|
+
pushCampaignObject != undefined ? handler(pushCampaignObject) : null;
|
|
42
|
+
}
|
|
31
43
|
}
|
|
32
|
-
|
|
44
|
+
|
|
45
|
+
}}
|
|
33
46
|
}
|
|
34
47
|
}
|