react-native-moengage 7.4.1 → 8.1.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 (55) hide show
  1. package/CHANGELOG.md +72 -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 +57 -22
  7. package/android/src/main/java/com/moengage/react/MoEInitializer.kt +44 -13
  8. package/android/src/main/java/com/moengage/react/MoEReactBridge.kt +116 -82
  9. package/android/src/main/java/com/moengage/react/MoEReactHelper.kt +2 -2
  10. package/android/src/main/java/com/moengage/react/PayloadGenerator.kt +41 -17
  11. package/iOS/MoEReactBridge/MoEReactBridge.h +1 -1
  12. package/iOS/MoEReactBridge/MoEReactBridge.m +34 -60
  13. package/iOS/MoEReactBridge/MoEngageInitializer.h +61 -0
  14. package/iOS/MoEReactBridge/MoEngageInitializer.m +164 -0
  15. package/iOS/MoEReactBridge/{MoEReactConstants.h → MoEngageReactConstants.h} +13 -3
  16. package/iOS/MoEReactBridge/{MoEReactConstants.m → MoEngageReactConstants.m} +14 -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 +196 -208
  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/models/MoEngagePermissionType.ts +3 -0
  41. package/src/models/MoEngagePersimissionResultData.ts +14 -0
  42. package/src/moeParser/MoEInAppParser.ts +192 -0
  43. package/src/moeParser/MoEPushNotificationParser.ts +78 -0
  44. package/src/moeParser/MoEngagePayloadParser.ts +11 -0
  45. package/src/platform/MoERNAndroid.ts +62 -92
  46. package/src/platform/MoERNiOS.ts +27 -60
  47. package/src/utils/MoEConstants.ts +61 -0
  48. package/src/utils/MoEEventHandlerHelper.ts +47 -28
  49. package/src/utils/MoEJsonBuilder.ts +229 -0
  50. package/src/utils/MoEObjectToJson.ts +44 -0
  51. package/iOS/MoEReactBridge/MOReactInitializer.h +0 -46
  52. package/iOS/MoEReactBridge/MOReactInitializer.m +0 -172
  53. package/iOS/MoEReactBridge/MOReactPluginInfo.h +0 -2
  54. package/src/models/MoEInAppCampaign.ts +0 -46
  55. package/src/models/MoEInAppSelfHandledCampaign.ts +0 -34
@@ -5,15 +5,16 @@ import com.facebook.react.bridge.Promise
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.bridge.ReactContextBaseJavaModule
7
7
  import com.facebook.react.bridge.ReactMethod
8
- import com.moe.pushlibrary.MoEHelper
9
- import com.moengage.core.internal.MoEConstants
8
+ import com.moengage.core.LogLevel
9
+ import com.moengage.core.internal.LIB_VERSION
10
10
  import com.moengage.core.internal.logger.Logger
11
- import com.moengage.plugin.base.PluginHelper
11
+ import com.moengage.plugin.base.internal.PluginHelper
12
+ import com.moengage.plugin.base.internal.setEventEmitter
12
13
 
13
14
  /**
14
15
  * @author Umang Chamaria
15
16
  */
16
- class MoEReactBridge(reactContext: ReactApplicationContext) :
17
+ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
17
18
  ReactContextBaseJavaModule(reactContext) {
18
19
 
19
20
  private val tag = "${MODULE_TAG}MoEReactBridge"
@@ -25,143 +26,144 @@ class MoEReactBridge(reactContext: ReactApplicationContext) :
25
26
  return "MoEReactBridge"
26
27
  }
27
28
 
29
+ @ReactMethod
30
+ fun addListener(eventName:String) {
31
+ // Keep: Required for RN built in Event Emitter Calls.
32
+ }
33
+
34
+ @ReactMethod
35
+ fun removeListeners(count:Int) {
36
+ // Keep: Required for RN built in Event Emitter Calls.
37
+ }
38
+
28
39
  @ReactMethod
29
40
  fun setAppStatus(payload: String) {
30
41
  try {
31
- Logger.v("$tag setAppStatus() : Payload: $payload")
42
+ Logger.print { "$tag setAppStatus() : Payload: $payload" }
32
43
  pluginHelper.setAppStatus(context, payload)
33
- } catch (e: Exception) {
34
- Logger.e("$tag setAppStatus() : ", e)
44
+ } catch (t: Throwable) {
45
+ Logger.print(LogLevel.ERROR, t) { "$tag setAppStatus() : " }
35
46
  }
36
47
  }
37
48
 
38
49
  @ReactMethod
39
50
  fun trackEvent(payload: String) {
40
51
  try {
41
- Logger.v("$tag trackEvent() : Payload: $payload")
52
+ Logger.print { "$tag trackEvent() : Payload: $payload" }
42
53
  pluginHelper.trackEvent(context, payload)
43
- } catch (e: Exception) {
44
- Logger.e("$tag trackEvent() : ", e)
54
+ } catch (t: Throwable) {
55
+ Logger.print(LogLevel.ERROR, t) { "$tag trackEvent() : " }
45
56
  }
46
57
  }
47
58
 
48
59
  @ReactMethod
49
60
  fun setUserAttribute(payload: String) {
50
61
  try {
51
- Logger.v("$tag setUserAttribute() : Payload: $payload")
62
+ Logger.print { "$tag setUserAttribute() : Payload: $payload" }
52
63
  pluginHelper.setUserAttribute(context, payload)
53
- } catch (e: Exception) {
54
- Logger.e("$tag setUserAttribute() : ", e)
55
- }
56
- }
57
-
58
- @ReactMethod
59
- fun logout() {
60
- try {
61
- Logger.v("$tag logout() : ")
62
- MoEHelper.getInstance(context).logoutUser()
63
- } catch (e: Exception) {
64
- Logger.e("$tag logout() : ", e)
64
+ } catch (t: Throwable) {
65
+ Logger.print(LogLevel.ERROR, t) { "$tag setUserAttribute() : " }
65
66
  }
66
67
  }
67
68
 
68
69
  @ReactMethod
69
- fun enableLogs() {
70
+ fun logout(payload: String) {
70
71
  try {
71
- Logger.v("$tag enableLogs() : ")
72
- pluginHelper.enableSDKLogs()
73
- } catch (e: Exception) {
74
- Logger.e("$tag enableLogs() : ", e)
72
+ Logger.print { "$tag logout() : " }
73
+ pluginHelper.logout(context, payload)
74
+ } catch (t: Throwable) {
75
+ Logger.print(LogLevel.ERROR, t) { "$tag logout() : " }
75
76
  }
76
77
  }
77
78
 
78
79
  @ReactMethod
79
80
  fun setAlias(payload: String) {
80
81
  try {
81
- Logger.v("$tag setAlias() : Payload: $payload")
82
+ Logger.print { "$tag setAlias() : Payload: $payload" }
82
83
  pluginHelper.setAlias(context, payload)
83
- } catch (e: Exception) {
84
- Logger.e("$tag setAlias() : ", e)
84
+ } catch (t: Throwable) {
85
+ Logger.print(LogLevel.ERROR, t) { "$tag setAlias() : " }
85
86
  }
86
87
  }
87
88
 
88
89
  @ReactMethod
89
90
  fun setAppContext(payload: String) {
90
91
  try {
91
- Logger.v("$tag setAppContext() : Payload: $payload")
92
+ Logger.print { "$tag setAppContext() : Payload: $payload" }
92
93
  pluginHelper.setAppContext(context, payload)
93
- } catch (e: Exception) {
94
- Logger.e("$tag setAppContext() : ", e)
94
+ } catch (t: Throwable) {
95
+ Logger.print(LogLevel.ERROR, t) { "$tag setAppContext() : " }
95
96
  }
96
97
  }
97
98
 
98
99
  @ReactMethod
99
- fun resetAppContext() {
100
+ fun resetAppContext(payload: String) {
100
101
  try {
101
- Logger.v("$tag resetAppContext() : ")
102
- pluginHelper.resetAppContext(context)
103
- } catch (e: Exception) {
104
- Logger.e("$tag resetAppContext() : ", e)
102
+ Logger.print { "$tag resetAppContext() : $payload" }
103
+ pluginHelper.resetAppContext(context, payload)
104
+ } catch (t: Throwable) {
105
+ Logger.print(LogLevel.ERROR, t) { "$tag resetAppContext() : " }
105
106
  }
106
107
  }
107
108
 
108
109
  @ReactMethod
109
- fun showInApp() {
110
+ fun showInApp(payload: String) {
110
111
  try {
111
- Logger.v("$tag showInApp() : Will attempt to show in-app.")
112
- pluginHelper.showInApp(context)
113
- } catch (e: Exception) {
114
- Logger.e("$tag showInApp() : ", e)
112
+ Logger.print { "$tag showInApp() : $payload" }
113
+ pluginHelper.showInApp(context, payload)
114
+ } catch (t: Throwable) {
115
+ Logger.print(LogLevel.ERROR, t) { "$tag showInApp() : " }
115
116
  }
116
117
  }
117
118
 
118
119
  @ReactMethod
119
- fun getSelfHandledInApp() {
120
+ fun getSelfHandledInApp(payload: String) {
120
121
  try {
121
- Logger.v("$tag getSelfHandledInApp() : Will try to fetch self-handled in-app")
122
- pluginHelper.getSelfHandledInApp(context)
123
- } catch (e: Exception) {
124
- Logger.e("$tag getSelfHandledInApp() : ", e)
122
+ Logger.print { "$tag getSelfHandledInApp() : $payload" }
123
+ pluginHelper.getSelfHandledInApp(context, payload)
124
+ } catch (t: Throwable) {
125
+ Logger.print(LogLevel.ERROR, t) { "$tag getSelfHandledInApp() : " }
125
126
  }
126
127
  }
127
128
 
128
129
  @ReactMethod
129
130
  fun passPushToken(payload: String) {
130
131
  try {
131
- Logger.v("$tag passPushToken() : Payload: $payload")
132
+ Logger.print { "$tag passPushToken() : $payload" }
132
133
  pluginHelper.passPushToken(context, payload)
133
- } catch (e: Exception) {
134
- Logger.e("$tag passPushToken() : ", e)
134
+ } catch (t: Throwable) {
135
+ Logger.print(LogLevel.ERROR, t) { "$tag passPushToken() : " }
135
136
  }
136
137
  }
137
138
 
138
139
  @ReactMethod
139
140
  fun passPushPayload(payload: String) {
140
141
  try {
141
- Logger.v("$tag passPushPayload() : Payload: $payload")
142
+ Logger.print { "$tag passPushPayload() : $payload" }
142
143
  pluginHelper.passPushPayload(context, payload)
143
- } catch (e: Exception) {
144
- Logger.e("$tag passPushPayload() : ", e)
144
+ } catch (t: Throwable) {
145
+ Logger.print(LogLevel.ERROR, t) { "$tag passPushPayload() : " }
145
146
  }
146
147
  }
147
148
 
148
149
  @ReactMethod
149
- override fun initialize() {
150
+ fun initialize(payload: String) {
150
151
  try {
151
- Logger.v("$tag initialize() ")
152
- pluginHelper.initialize()
153
- } catch (e: Exception) {
154
- Logger.e("$tag initialize() : ", e)
152
+ Logger.print { "$tag initialize() : " }
153
+ pluginHelper.initialise(payload)
154
+ setEventEmitter(EventEmitterImpl(reactContext))
155
+ } catch (t: Throwable) {
156
+ Logger.print(LogLevel.ERROR, t) { "$tag initialize() : " }
155
157
  }
156
158
  }
157
159
 
158
160
  @ReactMethod
159
161
  fun selfHandledCallback(payload: String) {
160
162
  try {
161
- Logger.v("$tag selfHandledCallback() : $payload")
163
+ Logger.print { "$tag selfHandledCallback() : $payload" }
162
164
  pluginHelper.selfHandledCallback(context, payload)
163
- } catch (e: Exception) {
164
- Logger.e("$tag selfHandledCallback() : ", e)
165
+ } catch (t: Throwable) {
166
+ Logger.print(LogLevel.ERROR, t) { "$tag selfHandledCallback() : " }
165
167
  }
166
168
  }
167
169
 
@@ -169,19 +171,19 @@ class MoEReactBridge(reactContext: ReactApplicationContext) :
169
171
  fun optOutTracking(payload: String) {
170
172
  try {
171
173
  pluginHelper.optOutTracking(context, payload)
172
- } catch (e: Exception) {
173
- Logger.e("$tag optOutTracking() : ", e)
174
+ } catch (t: Throwable) {
175
+ Logger.print(LogLevel.ERROR, t) { "$tag optOutTracking() : " }
174
176
  }
175
177
  }
176
178
 
177
179
  @ReactMethod
178
180
  fun validateSdkVersion(promise: Promise) {
179
- Logger.v("$tag validateSdkVersion() : Validating version")
180
- if (MoEConstants.LIB_VERSION > 12000) {
181
- Logger.e("$tag validateSdkVersion() : invalid version")
182
- promise.reject("error", "Use SDK version 11.x.xx")
181
+ Logger.print { "$tag validateSdkVersion() : Validating Version" }
182
+ if (LIB_VERSION > 13000) {
183
+ Logger.print(LogLevel.ERROR) { "$tag validateSdkVersion() : invalid version" }
184
+ promise.reject("error", "Use SDK version 12.x.xx")
183
185
  } else {
184
- Logger.v("$tag validateSdkVersion() : valid version")
186
+ Logger.print { "$tag validateSdkVersion() : valid version" }
185
187
  promise.resolve("valid version");
186
188
  }
187
189
  }
@@ -189,35 +191,67 @@ class MoEReactBridge(reactContext: ReactApplicationContext) :
189
191
  @ReactMethod
190
192
  fun updateSdkState(payload: String) {
191
193
  try {
192
- Logger.v("$tag updateSdkState() : $payload")
194
+ Logger.print { "$tag updateSdkState() : $payload" }
193
195
  pluginHelper.storeFeatureStatus(context, payload)
194
- } catch (e: Exception) {
195
- Logger.e("$tag updateSdkState() : ", e)
196
+ } catch (t: Throwable) {
197
+ Logger.print(LogLevel.ERROR, t) { "$tag updateSdkState() : " }
196
198
  }
197
199
  }
198
200
 
199
201
  @ReactMethod
200
202
  fun onOrientationChanged() {
201
- try{
202
- Logger.v("$tag onScreenOrientationChanged(): ")
203
+ try {
204
+ Logger.print { "$tag onOrientationChanged() : " }
203
205
  pluginHelper.onConfigurationChanged()
204
- }catch(e: Exception){
205
- Logger.e("$tag onScreenOrientationChanged() : ", e)
206
+ } catch (t: Throwable) {
207
+ Logger.print(LogLevel.ERROR, t) { "$tag onOrientationChanged() : " }
206
208
  }
207
209
  }
208
210
 
209
211
  @ReactMethod
210
212
  fun deviceIdentifierTrackingStatusUpdate(payload: String) {
211
213
  try {
212
- Logger.v("$tag deviceIdentifierTrackingStatusUpdate(): $payload")
214
+ Logger.print { "$tag deviceIdentifierTrackingStatusUpdate() : $payload" }
213
215
  pluginHelper.deviceIdentifierTrackingStatusUpdate(context, payload)
214
- } catch (e: Exception) {
215
- Logger.e("$tag deviceIdentifierTrackingStatusUpdate() : ", e)
216
+ } catch (t: Throwable) {
217
+ Logger.print(LogLevel.ERROR, t) { "$tag deviceIdentifierTrackingStatusUpdate() : " }
218
+ }
219
+ }
220
+
221
+ @ReactMethod
222
+ fun setupNotificationChannels() {
223
+ try {
224
+ pluginHelper.setUpNotificationChannels(context)
225
+ } catch (t: Throwable) {
226
+ Logger.print(LogLevel.ERROR, t) { "$tag setupNotificationChannel() :" }
227
+ }
228
+ }
229
+
230
+ @ReactMethod
231
+ fun navigateToSettings() {
232
+ try {
233
+ pluginHelper.navigateToSettings(context)
234
+ } catch (t: Throwable) {
235
+ Logger.print(LogLevel.ERROR, t) { "$tag navigateToSettings() :" }
216
236
  }
217
237
  }
218
238
 
239
+ @ReactMethod
240
+ fun requestPushPermission() {
241
+ try {
242
+ pluginHelper.requestPushPermission(context)
243
+ } catch (t: Throwable) {
244
+ Logger.print(LogLevel.ERROR, t) { "$tag requestPushPermission() :" }
245
+ }
246
+ }
219
247
 
220
- init {
221
- pluginHelper.setEventCallback(EventEmitterImpl(reactContext))
248
+ @ReactMethod
249
+ fun permissionResponse(payload: String) {
250
+ try {
251
+ Logger.print { "$tag permissionResponse() : Payload: $payload" }
252
+ pluginHelper.permissionResponse(context, payload)
253
+ } catch (t: Throwable) {
254
+ Logger.print(LogLevel.ERROR, t) { "$tag permissionResponse() :" }
255
+ }
222
256
  }
223
257
  }
@@ -13,8 +13,8 @@ public class MoEReactHelper {
13
13
  private val tag = "${MODULE_TAG}MoEReactHelper"
14
14
 
15
15
  public fun onConfigurationChanged() {
16
- if (!InAppManager.getInstance().hasModule()){
17
- Logger.v("$tag onConfigurationChanged(): InApp Module not present.")
16
+ if (!InAppManager.hasModule()){
17
+ Logger.print { "$tag onConfigurationChanged() : InApp Module not present." }
18
18
  return
19
19
  }
20
20
  MoEInAppHelper.getInstance().onConfigurationChanged()
@@ -3,43 +3,67 @@ package com.moengage.react
3
3
  import com.facebook.react.bridge.Arguments
4
4
  import com.facebook.react.bridge.WritableMap
5
5
  import com.moengage.core.internal.logger.Logger
6
- import com.moengage.inapp.model.MoEInAppCampaign
7
- import com.moengage.plugin.base.ARGUMENT_PAYLOAD
8
- import com.moengage.plugin.base.inAppCampaignToJson
9
- import com.moengage.plugin.base.model.PushPayload
10
- import com.moengage.plugin.base.model.PushToken
11
- import com.moengage.plugin.base.pushPayloadToJson
12
- import com.moengage.plugin.base.pushTokenToJson
6
+ import com.moengage.inapp.model.ClickData
7
+ import com.moengage.inapp.model.InAppData
8
+ import com.moengage.inapp.model.SelfHandledCampaignData
9
+ import com.moengage.plugin.base.internal.*
10
+ import com.moengage.plugin.base.internal.model.PermissionResult
11
+ import com.moengage.plugin.base.internal.model.PushPayload
12
+ import com.moengage.plugin.base.internal.model.events.push.TokenEvent
13
13
 
14
14
  /**
15
15
  * @author Umang Chamaria
16
16
  * Date: 2020/07/29
17
17
  */
18
- class PayloadGenerator {
18
+ internal class PayloadGenerator {
19
19
 
20
20
  private val tag = "${MODULE_TAG}PayloadGenerator"
21
21
 
22
22
  fun pushPayloadToWriteableMap(payload: PushPayload): WritableMap {
23
23
  val map = Arguments.createMap()
24
24
  val pushJson = pushPayloadToJson(payload)
25
- Logger.v("$tag pushPayloadToWriteableMap() : $pushJson")
25
+ Logger.print { "$tag pushPayloadToWriteableMap() : $pushJson" }
26
26
  map.putString(ARGUMENT_PAYLOAD, pushJson.toString())
27
27
  return map
28
28
  }
29
29
 
30
- fun inAppCampaignToWriteableMap(inAppCampaign: MoEInAppCampaign): WritableMap {
30
+ fun tokenToWriteableMap(pushToken: TokenEvent) : WritableMap{
31
31
  val map = Arguments.createMap()
32
- val inAppJson = inAppCampaignToJson(inAppCampaign)
33
- Logger.v("$tag inAppCampaignToWriteableMap() : $inAppJson")
34
- map.putString(ARGUMENT_PAYLOAD, inAppJson.toString())
32
+ val tokenJson = tokenEventToJson(pushToken)
33
+ Logger.print { "$tag tokenToWriteableMap() : $tokenJson" }
34
+ map.putString(ARGUMENT_PAYLOAD, tokenJson.toString())
35
35
  return map
36
36
  }
37
37
 
38
- fun tokenToWriteableMap(pushToken: PushToken) : WritableMap{
38
+ fun inAppNavigationToWriteableMap(clickData: ClickData): WritableMap {
39
39
  val map = Arguments.createMap()
40
- val tokenJson = pushTokenToJson(pushToken)
41
- Logger.v("$tag tokenToWriteableMap() : $tokenJson")
42
- map.putString(ARGUMENT_PAYLOAD, tokenJson.toString())
40
+ val json = clickDataToJson(clickData)
41
+ Logger.print { "$tag inAppNavigationToWriteableMap() : $json" }
42
+ map.putString(ARGUMENT_PAYLOAD, json.toString())
43
+ return map
44
+ }
45
+
46
+ fun inAppDataToWriteableMap(inAppData: InAppData): WritableMap {
47
+ val map = Arguments.createMap()
48
+ val json = inAppDataToJson(inAppData)
49
+ Logger.print { "$tag inAppDataToWriteableMap() : $json" }
50
+ map.putString(ARGUMENT_PAYLOAD, json.toString())
51
+ return map
52
+ }
53
+
54
+ fun selfHandledDataToWriteableMap(data: SelfHandledCampaignData): WritableMap {
55
+ val map = Arguments.createMap()
56
+ val json = selfHandledDataToJson(data)
57
+ Logger.print { "$tag selfHandledDataToWriteableMap() : $data" }
58
+ map.putString(ARGUMENT_PAYLOAD, json.toString())
59
+ return map
60
+ }
61
+
62
+ fun permissionResultToWriteableMap(result: PermissionResult): WritableMap {
63
+ val map = Arguments.createMap()
64
+ val json = permissionResultToJson(result)
65
+ Logger.print { "$tag permissionResultToWriteableMap() : Payload Json: $json" }
66
+ map.putString(ARGUMENT_PAYLOAD, json.toString())
43
67
  return map
44
68
  }
45
69
  }
@@ -1,5 +1,5 @@
1
1
  //
2
- // MoEngageManager.h
2
+ // MoEngageReactBridge.h
3
3
  // MoEngage
4
4
  //
5
5
  // Created by Chengappa C D on 11/11/16.
@@ -1,5 +1,5 @@
1
1
  //
2
- // MoEngageManager.m
2
+ // MoEReactBridge.m
3
3
  // MoEngage
4
4
  //
5
5
  // Created by Chengappa C D on 11/11/16.
@@ -10,10 +10,10 @@
10
10
  #import <React/RCTLog.h>
11
11
  #import <React/RCTConvert.h>
12
12
  #import <React/RCTBundleURLProvider.h>
13
- #import <MoEPluginBase/MoEPluginBase.h>
14
- #import <MoEngage/MoEngage.h>
15
- #import "MOReactInitializer.h"
16
- #import "MoEReactConstants.h"
13
+ #import "MoEngageInitializer.h"
14
+ #import "MoEngageReactConstants.h"
15
+ @import MoEngagePluginBase;
16
+ @import MoEngageSDK;
17
17
 
18
18
  @interface MoEReactBridge()
19
19
  @end
@@ -91,129 +91,103 @@
91
91
  #pragma mark- Event Emitters
92
92
  - (NSArray<NSString *> *)supportedEvents
93
93
  {
94
- return @[kEventNamePushClicked,kEventNamePushTokenGenerated,kEventNameInAppCampaignShown,kEventNameInAppCampaignClicked, kEventNameInAppCampaignDismissed, kEventNameInAppSelfHandledCampaign, kEventNameInAppCampaignCustomAction];
94
+ return @[kPushClicked, kPushTokenGenerated, kInAppShown, kInAppClicked, kInAppDismissed, kInAppCustomAction, kInAppSelfHandled, kPermissionResult];
95
95
  }
96
96
 
97
97
  RCT_EXPORT_MODULE();
98
98
 
99
99
  #pragma mark- Initialization Method
100
100
 
101
- RCT_EXPORT_METHOD(initialize)
101
+ RCT_EXPORT_METHOD(initialize:(NSDictionary *)payload)
102
102
  {
103
- [[MoEPluginBridge sharedInstance] pluginInitialized];
103
+ [[MoEngagePluginBridge sharedInstance] pluginInitialized:payload];
104
104
  }
105
105
 
106
106
  #pragma mark- Set AppStatus
107
107
 
108
- RCT_EXPORT_METHOD(setAppStatus:(NSDictionary *)dictStatus)
108
+ RCT_EXPORT_METHOD(setAppStatus:(NSDictionary *)payload)
109
109
  {
110
- [[MoEPluginBridge sharedInstance] setAppStatus:dictStatus];
110
+ [[MoEngagePluginBridge sharedInstance] setAppStatus:payload];
111
111
  }
112
112
 
113
113
  #pragma mark - trackEvent
114
114
 
115
- RCT_EXPORT_METHOD(trackEventWithProperties:(NSDictionary *)attributes)
115
+ RCT_EXPORT_METHOD(trackEventWithProperties:(NSDictionary *)payload)
116
116
  {
117
- [[MoEPluginBridge sharedInstance] trackEventWithPayload:attributes];
117
+ [[MoEngagePluginBridge sharedInstance] trackEvent:payload];
118
118
  }
119
119
 
120
120
  #pragma mark- User Attribute Methods
121
- #pragma mark setUserAttribute
122
- RCT_EXPORT_METHOD(setUserAttribute:(NSDictionary *)userAttributeDict)
121
+ RCT_EXPORT_METHOD(setUserAttribute:(NSDictionary *)payload)
123
122
  {
124
- [[MoEPluginBridge sharedInstance] setUserAttributeWithPayload:userAttributeDict];
123
+ [[MoEngagePluginBridge sharedInstance] setUserAttribute:payload];
125
124
  }
126
125
 
127
- RCT_EXPORT_METHOD(setAlias:(NSDictionary *)aliasDictionary)
126
+ RCT_EXPORT_METHOD(setAlias:(NSDictionary *)payload)
128
127
  {
129
- [[MoEPluginBridge sharedInstance] setAlias:aliasDictionary];
128
+ [[MoEngagePluginBridge sharedInstance] setAlias:payload];
130
129
  }
131
130
 
132
131
  #pragma mark- Push Notifications
133
-
134
132
  RCT_EXPORT_METHOD(registerForPushNotification)
135
133
  {
136
- [[MoEPluginBridge sharedInstance] registerForPush];
134
+ [[MoEngagePluginBridge sharedInstance] registerForPush];
137
135
  }
138
136
 
139
- #pragma mark Disable Inbox
140
-
141
- RCT_EXPORT_METHOD(disableInbox)
142
- {
143
- [MOMessaging sharedInstance].disableInbox = YES;
144
- }
145
-
146
- #pragma mark- inApp Methods
147
137
  #pragma mark Show InApp
148
138
 
149
- RCT_EXPORT_METHOD(showInApp)
139
+ RCT_EXPORT_METHOD(showInApp:(NSDictionary *)payload)
150
140
  {
151
- [[MoEPluginBridge sharedInstance] showInApp];
141
+ [[MoEngagePluginBridge sharedInstance] showInApp:payload];
152
142
  }
153
143
 
154
144
  #pragma mark Self handled In App
155
145
 
156
- RCT_EXPORT_METHOD(getSelfHandledInApp)
146
+ RCT_EXPORT_METHOD(getSelfHandledInApp:(NSDictionary *)payload)
157
147
  {
158
- [[MoEPluginBridge sharedInstance] getSelfHandledInApp];
148
+ [[MoEngagePluginBridge sharedInstance] getSelfHandledInApp:payload];
159
149
  }
160
150
 
161
- RCT_EXPORT_METHOD(updateSelfHandledInAppStatusWithPayload:(NSDictionary *)campInfo) {
162
- [[MoEPluginBridge sharedInstance] updateSelfHandledInAppStatusWithPayload:campInfo];
151
+ RCT_EXPORT_METHOD(updateSelfHandledInAppStatusWithPayload:(NSDictionary *)payload) {
152
+ [[MoEngagePluginBridge sharedInstance] updateSelfHandledImpression:payload];
163
153
  }
164
154
 
165
155
  #pragma mark InApp Contexts
166
156
 
167
- RCT_EXPORT_METHOD(setAppContext:(nonnull NSDictionary *)dictContext)
157
+ RCT_EXPORT_METHOD(setAppContext:(nonnull NSDictionary *)payload)
168
158
  {
169
- [[MoEPluginBridge sharedInstance] setInAppContexts:dictContext];
159
+ [[MoEngagePluginBridge sharedInstance] setInAppContext:payload];
170
160
  }
171
161
 
172
- RCT_EXPORT_METHOD(resetAppContext)
162
+ RCT_EXPORT_METHOD(resetAppContext:(NSDictionary *)payload)
173
163
  {
174
- [[MoEPluginBridge sharedInstance] invalidateInAppContexts];
175
- }
176
-
177
-
178
- #pragma mark- Enable SDK Logs
179
-
180
- RCT_EXPORT_METHOD(enableSDKLogs)
181
- {
182
- [[MoEPluginBridge sharedInstance] enableLogs];
164
+ [[MoEngagePluginBridge sharedInstance] resetInAppContext:payload];
183
165
  }
184
166
 
185
167
  #pragma mark- Reset User
186
168
 
187
- RCT_EXPORT_METHOD(logout)
169
+ RCT_EXPORT_METHOD(logout:(NSDictionary *)payload)
188
170
  {
189
- [[MoEPluginBridge sharedInstance] resetUser];
171
+ [[MoEngagePluginBridge sharedInstance] resetUser:payload];
190
172
  }
191
173
 
192
- #pragma mark- Validate App version
193
-
194
174
  RCT_EXPORT_METHOD(validateSDKVersion:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
195
175
  {
196
- if ([[MoEPluginBridge sharedInstance] isValidNativeDependencyIntegrated]) {
176
+ if ([[MoEngagePluginBridge sharedInstance] validateSDKVersion]) {
197
177
  resolve([NSNumber numberWithBool:YES]);
198
178
  } else {
199
179
  reject(NULL, @"MoEngage: Unsupported SDK version", NULL);
200
180
  }
201
181
  }
202
182
 
203
- #pragma mark- GeoFence Monitoring
204
- RCT_EXPORT_METHOD(startGeofenceMonitoring) {
205
- // Init Geofence if included
206
- [[MoEPluginBridge sharedInstance] startGeofenceMonitoring];
207
- }
208
-
209
183
  #pragma mark- Opt out Tracking
210
- RCT_EXPORT_METHOD(optOutTracking:(nonnull NSDictionary *)dictTracking) {
211
- [[MoEPluginBridge sharedInstance] optOutTracking:dictTracking];
184
+ RCT_EXPORT_METHOD(optOutTracking:(nonnull NSDictionary *)payload) {
185
+ [[MoEngagePluginBridge sharedInstance] optOutDataTracking:payload];
212
186
  }
213
187
 
214
188
  #pragma mark- Update SDK State
215
- RCT_EXPORT_METHOD(updateSDKState:(nonnull NSDictionary *)stateDict) {
216
- [[MoEPluginBridge sharedInstance] updateSDKState:stateDict];
189
+ RCT_EXPORT_METHOD(updateSDKState:(nonnull NSDictionary *)payload) {
190
+ [[MoEngagePluginBridge sharedInstance] updateSDKState:payload];
217
191
  }
218
192
 
219
193
  @end