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 CHANGED
@@ -1,3 +1,34 @@
1
+ # 14-05-2024
2
+
3
+ ## 10.0.1
4
+ - BugFix
5
+ - Adding backward compatibility support for react-native version with react-native-moengage `10.x.x`
6
+
7
+ # 07-05-2024
8
+
9
+ ## 10.0.0
10
+ - Added support for Turbo Architecture
11
+ - Breaking APIs in Javascript
12
+
13
+ | Then | Now |
14
+ |:------------:|:-----------------:|
15
+ | optOutDataTracking(false) | enableDataTracking() |
16
+ | optOutDataTracking(true) | disableDataTracking() |
17
+
18
+
19
+ - iOS
20
+ - Removed support for SDK initialization from Info.plist.
21
+ - Removed APIs
22
+
23
+ | Removed APIs |
24
+ |:---------------------------:|
25
+ | - (void)initializeDefaultInstance:(NSDictionary*)launchOptions; |
26
+ | - (void)initializeDefaultInstanceWithState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions; |
27
+ | - (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions; |
28
+ | - (void)initializeDefaultSDKConfig:(MoEngageSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions |
29
+ - Android
30
+ - Making `moe-android-sdk` and `inapp` dependecies as implementation
31
+
1
32
  # 08-04-2024
2
33
 
3
34
  ## 9.1.0
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
13
13
  s.authors = "MoEngage Inc."
14
14
  s.source = {:file => './' }
15
15
  s.platforms = { :ios => "11.0", :tvos => "11.0" }
16
- s.source_files = 'iOS/MoEReactBridge/**/*.{h,m}'
16
+ s.source_files = 'iOS/MoEReactBridge/**/*.{h,m,mm}'
17
17
  s.dependency 'React'
18
18
  s.dependency 'MoEngagePluginBase','>= 4.8.0','< 4.9.0'
19
19
  s.ios.dependency 'MoEngageRichNotification','>= 7.16.0','< 7.17.0'
@@ -22,4 +22,11 @@ Pod::Spec.new do |s|
22
22
  echo // Generated file, do not edit > iOS/MoEReactBridge/MoEngageReactPluginInfo.h
23
23
  echo "#define MOE_REACT_PLUGIN_VERSION @\\"#{package["version"]}\\"" >> iOS/MoEReactBridge/MoEngageReactPluginInfo.h
24
24
  CMD
25
+
26
+
27
+ if defined?(install_modules_dependencies()) != nil
28
+ install_modules_dependencies(s);
29
+ else
30
+ s.dependency "React-Core"
31
+ end
25
32
  end
@@ -20,8 +20,8 @@ rootProject.allprojects {
20
20
 
21
21
  ext {
22
22
  //dependency version
23
- moengageCoreVersion = "13.00.01"
24
- moengageInAppVersion = "8.1.0"
23
+ moengageCoreVersion = "13.00.03"
24
+ moengageInAppVersion = "8.2.1"
25
25
  basePluginVersion = "4.0.0"
26
26
  //build versions
27
27
  minimumVersion = 21
@@ -30,6 +30,7 @@ ext {
30
30
 
31
31
  apply plugin: 'com.android.library'
32
32
  apply plugin: 'kotlin-android'
33
+ apply plugin: 'com.facebook.react'
33
34
 
34
35
  android {
35
36
  compileSdk compileVersion
@@ -40,6 +41,8 @@ android {
40
41
  versionName "1.0"
41
42
 
42
43
  testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
44
+
45
+ buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
43
46
  }
44
47
  buildTypes {
45
48
  release {
@@ -59,19 +62,28 @@ android {
59
62
  buildFeatures {
60
63
  buildConfig true
61
64
  }
65
+
66
+
67
+ sourceSets {
68
+ main {
69
+ if (isNewArchitectureEnabled()) {
70
+ java.srcDirs += ['src/newarch']
71
+ } else {
72
+ java.srcDirs += ['src/oldarch']
73
+ }
74
+ }
75
+ }
62
76
  }
63
77
 
64
78
  dependencies {
65
79
  implementation fileTree(include: ['*.jar'], dir: 'libs')
66
80
 
81
+ compileOnly('com.facebook.react:react-native')
67
82
  compileOnly("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
68
83
 
69
- compileOnly ("com.moengage:moe-android-sdk:$moengageCoreVersion")
84
+ api("com.moengage:moe-android-sdk:$moengageCoreVersion")
85
+ api("com.moengage:inapp:$moengageInAppVersion")
70
86
  api("com.moengage:plugin-base:$basePluginVersion")
71
- compileOnly("com.moengage:inapp:$moengageInAppVersion")
72
-
73
- compileOnly 'com.facebook.react:react-native:+'
74
-
75
87
  }
76
88
 
77
89
  apply from: file("./user-agent.gradle")
@@ -79,3 +91,7 @@ apply from: file("./user-agent.gradle")
79
91
  repositories {
80
92
  mavenCentral()
81
93
  }
94
+
95
+ def isNewArchitectureEnabled() {
96
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
97
+ }
@@ -1,49 +1,47 @@
1
+ /*
2
+ * Copyright (c) 2014-2024 MoEngage Inc.
3
+ *
4
+ * All rights reserved.
5
+ *
6
+ * Use of source code or binaries contained within MoEngage SDK is permitted only to enable use of the MoEngage platform by customers of MoEngage.
7
+ * Modification of source code and inclusion in mobile apps is explicitly allowed provided that all other conditions are met.
8
+ * Neither the name of MoEngage nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
+ * Redistribution of source code or binaries is disallowed except with specific prior written permission. Any such redistribution must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ *
11
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
+ */
13
+
1
14
  package com.moengage.react
2
15
 
3
16
  import android.content.Context
4
17
  import com.facebook.react.bridge.Promise
5
18
  import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.bridge.ReactContextBaseJavaModule
7
- import com.facebook.react.bridge.ReactMethod
8
19
  import com.moengage.core.LogLevel
9
20
  import com.moengage.core.MoECoreHelper
10
21
  import com.moengage.core.internal.logger.Logger
11
- import com.moengage.core.internal.utils.getSdkVersion
12
22
  import com.moengage.core.listeners.AppBackgroundListener
13
23
  import com.moengage.plugin.base.internal.PluginHelper
14
24
  import com.moengage.plugin.base.internal.setEventEmitter
15
25
  import com.moengage.plugin.base.internal.userDeletionDataToJson
16
26
 
17
27
  /**
18
- * @author Umang Chamaria
28
+ * Class to handle all the request from the [MoEReactBridge] from both old and new arch
29
+ *
30
+ * @author Abhishek Kumar
31
+ * @since Todo: Add Version
19
32
  */
20
- class MoEReactBridge(private val reactContext: ReactApplicationContext) :
21
- ReactContextBaseJavaModule(reactContext) {
33
+ internal class MoEReactBridgeHandler(private val reactContext: ReactApplicationContext) {
22
34
 
23
- private val tag = "${MODULE_TAG}MoEReactBridge"
35
+ private val tag = "${MODULE_TAG}MoEReactBridgeHandler"
24
36
 
25
37
  private val context: Context = reactContext.applicationContext
26
38
  private val pluginHelper = PluginHelper()
27
- private val moeSdkVersion = getSdkVersion()
28
39
 
29
40
  private val backgroundStateListener =
30
41
  AppBackgroundListener { _, _ -> pluginHelper.onFrameworkDetached() }
31
42
 
32
- override fun getName(): String {
33
- return "MoEReactBridge"
34
- }
35
-
36
- @ReactMethod
37
- fun addListener(eventName: String) {
38
- // Keep: Required for RN built in Event Emitter Calls.
39
- }
40
-
41
- @ReactMethod
42
- fun removeListeners(count: Int) {
43
- // Keep: Required for RN built in Event Emitter Calls.
44
- }
43
+ fun getName() = NAME
45
44
 
46
- @ReactMethod
47
45
  fun setAppStatus(payload: String) {
48
46
  try {
49
47
  Logger.print { "$tag setAppStatus() : Payload: $payload" }
@@ -53,7 +51,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
53
51
  }
54
52
  }
55
53
 
56
- @ReactMethod
57
54
  fun trackEvent(payload: String) {
58
55
  try {
59
56
  Logger.print { "$tag trackEvent() : Payload: $payload" }
@@ -63,7 +60,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
63
60
  }
64
61
  }
65
62
 
66
- @ReactMethod
67
63
  fun setUserAttribute(payload: String) {
68
64
  try {
69
65
  Logger.print { "$tag setUserAttribute() : Payload: $payload" }
@@ -73,17 +69,15 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
73
69
  }
74
70
  }
75
71
 
76
- @ReactMethod
77
72
  fun logout(payload: String) {
78
73
  try {
79
- Logger.print { "$tag logout() : " }
74
+ Logger.print { "$tag logout() : $payload" }
80
75
  pluginHelper.logout(context, payload)
81
76
  } catch (t: Throwable) {
82
77
  Logger.print(LogLevel.ERROR, t) { "$tag logout() : " }
83
78
  }
84
79
  }
85
80
 
86
- @ReactMethod
87
81
  fun setAlias(payload: String) {
88
82
  try {
89
83
  Logger.print { "$tag setAlias() : Payload: $payload" }
@@ -93,7 +87,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
93
87
  }
94
88
  }
95
89
 
96
- @ReactMethod
97
90
  fun setAppContext(payload: String) {
98
91
  try {
99
92
  Logger.print { "$tag setAppContext() : Payload: $payload" }
@@ -103,7 +96,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
103
96
  }
104
97
  }
105
98
 
106
- @ReactMethod
107
99
  fun resetAppContext(payload: String) {
108
100
  try {
109
101
  Logger.print { "$tag resetAppContext() : $payload" }
@@ -113,7 +105,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
113
105
  }
114
106
  }
115
107
 
116
- @ReactMethod
117
108
  fun showInApp(payload: String) {
118
109
  try {
119
110
  Logger.print { "$tag showInApp() : $payload" }
@@ -123,7 +114,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
123
114
  }
124
115
  }
125
116
 
126
- @ReactMethod
127
117
  fun getSelfHandledInApp(payload: String) {
128
118
  try {
129
119
  Logger.print { "$tag getSelfHandledInApp() : $payload" }
@@ -133,7 +123,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
133
123
  }
134
124
  }
135
125
 
136
- @ReactMethod
137
126
  fun passPushToken(payload: String) {
138
127
  try {
139
128
  Logger.print { "$tag passPushToken() : $payload" }
@@ -143,7 +132,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
143
132
  }
144
133
  }
145
134
 
146
- @ReactMethod
147
135
  fun passPushPayload(payload: String) {
148
136
  try {
149
137
  Logger.print { "$tag passPushPayload() : $payload" }
@@ -153,10 +141,9 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
153
141
  }
154
142
  }
155
143
 
156
- @ReactMethod
157
144
  fun initialize(payload: String) {
158
145
  try {
159
- Logger.print { "$tag initialize() : " }
146
+ Logger.print { "$tag initialize() : $payload" }
160
147
  pluginHelper.initialise(payload)
161
148
  setEventEmitter(EventEmitterImpl(reactContext))
162
149
  if (GlobalCache.lifecycleAwareCallbackEnabled) {
@@ -167,7 +154,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
167
154
  }
168
155
  }
169
156
 
170
- @ReactMethod
171
157
  fun selfHandledCallback(payload: String) {
172
158
  try {
173
159
  Logger.print { "$tag selfHandledCallback() : $payload" }
@@ -177,7 +163,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
177
163
  }
178
164
  }
179
165
 
180
- @ReactMethod
181
166
  fun optOutTracking(payload: String) {
182
167
  try {
183
168
  pluginHelper.optOutTracking(context, payload)
@@ -186,19 +171,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
186
171
  }
187
172
  }
188
173
 
189
- @ReactMethod
190
- fun validateSdkVersion(promise: Promise) {
191
- Logger.print { "$tag validateSdkVersion() : Validating Version" }
192
- if (moeSdkVersion > 140000) {
193
- Logger.print(LogLevel.ERROR) { "$tag validateSdkVersion() : invalid version" }
194
- promise.reject("error", "Use SDK version less than 14.xx.xx")
195
- } else {
196
- Logger.print { "$tag validateSdkVersion() : valid version" }
197
- promise.resolve("valid version");
198
- }
199
- }
200
-
201
- @ReactMethod
202
174
  fun updateSdkState(payload: String) {
203
175
  try {
204
176
  Logger.print { "$tag updateSdkState() : $payload" }
@@ -208,7 +180,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
208
180
  }
209
181
  }
210
182
 
211
- @ReactMethod
212
183
  fun onOrientationChanged() {
213
184
  try {
214
185
  Logger.print { "$tag onOrientationChanged() : " }
@@ -218,7 +189,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
218
189
  }
219
190
  }
220
191
 
221
- @ReactMethod
222
192
  fun deviceIdentifierTrackingStatusUpdate(payload: String) {
223
193
  try {
224
194
  Logger.print { "$tag deviceIdentifierTrackingStatusUpdate() : $payload" }
@@ -228,34 +198,33 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
228
198
  }
229
199
  }
230
200
 
231
- @ReactMethod
232
201
  fun setupNotificationChannels() {
233
202
  try {
203
+ Logger.print { "$tag setupNotificationChannels() : " }
234
204
  pluginHelper.setUpNotificationChannels(context)
235
205
  } catch (t: Throwable) {
236
206
  Logger.print(LogLevel.ERROR, t) { "$tag setupNotificationChannel() :" }
237
207
  }
238
208
  }
239
209
 
240
- @ReactMethod
241
210
  fun navigateToSettings() {
242
211
  try {
212
+ Logger.print { "$tag navigateToSettings() : " }
243
213
  pluginHelper.navigateToSettings(context)
244
214
  } catch (t: Throwable) {
245
215
  Logger.print(LogLevel.ERROR, t) { "$tag navigateToSettings() :" }
246
216
  }
247
217
  }
248
218
 
249
- @ReactMethod
250
219
  fun requestPushPermission() {
251
220
  try {
221
+ Logger.print { "$tag requestPushPermission() : " }
252
222
  pluginHelper.requestPushPermission(context)
253
223
  } catch (t: Throwable) {
254
224
  Logger.print(LogLevel.ERROR, t) { "$tag requestPushPermission() :" }
255
225
  }
256
226
  }
257
227
 
258
- @ReactMethod
259
228
  fun permissionResponse(payload: String) {
260
229
  try {
261
230
  Logger.print { "$tag permissionResponse() : Payload: $payload" }
@@ -265,7 +234,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
265
234
  }
266
235
  }
267
236
 
268
- @ReactMethod
269
237
  fun updatePushPermissionRequestCount(payload: String) {
270
238
  try {
271
239
  Logger.print { "$tag updatePushPermissionRequestCount() : Payload: $payload" }
@@ -275,14 +243,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
275
243
  }
276
244
  }
277
245
 
278
- /**
279
- * API to delete the user from MoEngage Server
280
-
281
- * @param payload - required key-value pair
282
- * @param promise - promise object which will be resolved based on success / failure
283
- * @since 8.6.0
284
- */
285
- @ReactMethod
286
246
  fun deleteUser(payload: String, promise: Promise) {
287
247
  try {
288
248
  Logger.print { "$tag deleteUser() : Payload: $payload" }
@@ -295,11 +255,6 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
295
255
  }
296
256
  }
297
257
 
298
- /**
299
- * Try to show a non-intrusive In-App nudge
300
- * @since Todo: Add Version
301
- */
302
- @ReactMethod
303
258
  fun showNudge(payload: String) {
304
259
  try {
305
260
  Logger.print { "$tag showNudge() : Payload: $payload" }
@@ -308,4 +263,8 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
308
263
  Logger.print(LogLevel.ERROR, t) { "$tag showNudge() :" }
309
264
  }
310
265
  }
266
+
267
+ companion object {
268
+ const val NAME = "MoEReactBridge"
269
+ }
311
270
  }
@@ -1,21 +1,51 @@
1
+ /*
2
+ * Copyright (c) 2014-2024 MoEngage Inc.
3
+ *
4
+ * All rights reserved.
5
+ *
6
+ * Use of source code or binaries contained within MoEngage SDK is permitted only to enable use of the MoEngage platform by customers of MoEngage.
7
+ * Modification of source code and inclusion in mobile apps is explicitly allowed provided that all other conditions are met.
8
+ * Neither the name of MoEngage nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
+ * Redistribution of source code or binaries is disallowed except with specific prior written permission. Any such redistribution must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ *
11
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
+ */
13
+
1
14
  package com.moengage.react
2
15
 
3
- import com.facebook.react.ReactPackage
16
+ import com.facebook.react.TurboReactPackage
4
17
  import com.facebook.react.bridge.NativeModule
5
18
  import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.uimanager.ViewManager
19
+ import com.facebook.react.module.model.ReactModuleInfo
20
+ import com.facebook.react.module.model.ReactModuleInfoProvider
7
21
 
8
22
  /**
9
23
  * @author Umang Chamaria
10
24
  */
11
- class MoEReactPackage : ReactPackage {
12
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
13
- val modules: MutableList<NativeModule> = ArrayList()
14
- modules.add(MoEReactBridge(reactContext))
15
- return modules
25
+ class MoEReactPackage : TurboReactPackage() {
26
+
27
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
28
+ return if (name == MoEReactBridgeHandler.NAME) {
29
+ MoEReactBridge(reactContext)
30
+ } else {
31
+ null
32
+ }
16
33
  }
17
34
 
18
- override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
19
- return emptyList()
35
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
36
+ return ReactModuleInfoProvider {
37
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
38
+ val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
39
+ moduleInfos[MoEReactBridgeHandler.NAME] = ReactModuleInfo(
40
+ MoEReactBridgeHandler.NAME,
41
+ MoEReactBridgeHandler.NAME,
42
+ false, // canOverrideExistingModule
43
+ false, // needsEagerInit
44
+ true, // hasConstants
45
+ false, // isCxxModule
46
+ isTurboModule // isTurboModule
47
+ )
48
+ moduleInfos
49
+ }
20
50
  }
21
51
  }
@@ -0,0 +1,143 @@
1
+ /*
2
+ * Copyright (c) 2014-2024 MoEngage Inc.
3
+ *
4
+ * All rights reserved.
5
+ *
6
+ * Use of source code or binaries contained within MoEngage SDK is permitted only to enable use of the MoEngage platform by customers of MoEngage.
7
+ * Modification of source code and inclusion in mobile apps is explicitly allowed provided that all other conditions are met.
8
+ * Neither the name of MoEngage nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
+ * Redistribution of source code or binaries is disallowed except with specific prior written permission. Any such redistribution must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ *
11
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
+ */
13
+
14
+ package com.moengage.react
15
+
16
+ import com.facebook.react.bridge.Promise
17
+ import com.facebook.react.bridge.ReactApplicationContext
18
+ import com.moengage.core.internal.logger.Logger
19
+
20
+ /**
21
+ * Bridge to communicate with js code in new arch
22
+ *
23
+ * @author Abhishek Kumar
24
+ * @since Todo: Add Version
25
+ */
26
+ class MoEReactBridge(reactContext: ReactApplicationContext) : NativeMoEngageSpec(reactContext) {
27
+
28
+ private val tag = "${MODULE_TAG}MoEReactBridge"
29
+ private val bridgeHandler = MoEReactBridgeHandler(reactContext)
30
+
31
+ override fun getName() = bridgeHandler.getName()
32
+
33
+ override fun addListener(eventType: String) {
34
+ }
35
+
36
+ override fun removeListeners(count: Double) {
37
+ }
38
+
39
+ override fun initialize(payload: String) {
40
+ Logger.print { "$tag initializing module in new arch" }
41
+ bridgeHandler.initialize(payload)
42
+ }
43
+
44
+ override fun setAppStatus(payload: String) {
45
+ bridgeHandler.setAppStatus(payload)
46
+ }
47
+
48
+ override fun trackEvent(payload: String) {
49
+ bridgeHandler.trackEvent(payload)
50
+ }
51
+
52
+ override fun setUserAttribute(payload: String) {
53
+ bridgeHandler.setUserAttribute(payload)
54
+ }
55
+
56
+ override fun setAlias(payload: String) {
57
+ bridgeHandler.setAlias(payload)
58
+ }
59
+
60
+ override fun logout(payload: String) {
61
+ bridgeHandler.logout(payload)
62
+ }
63
+
64
+ override fun showInApp(payload: String) {
65
+ bridgeHandler.showInApp(payload)
66
+ }
67
+
68
+ override fun showNudge(payload: String) {
69
+ bridgeHandler.showNudge(payload)
70
+ }
71
+
72
+ override fun getSelfHandledInApp(payload: String) {
73
+ bridgeHandler.getSelfHandledInApp(payload)
74
+ }
75
+
76
+ override fun updateSelfHandledInAppStatus(payload: String) {
77
+ bridgeHandler.selfHandledCallback(payload)
78
+ }
79
+
80
+ override fun setAppContext(payload: String) {
81
+ bridgeHandler.setAppContext(payload)
82
+ }
83
+
84
+ override fun resetAppContext(payload: String) {
85
+ bridgeHandler.resetAppContext(payload)
86
+ }
87
+
88
+ override fun optOutDataTracking(payload: String) {
89
+ bridgeHandler.optOutTracking(payload)
90
+ }
91
+
92
+ override fun updateSdkState(payload: String) {
93
+ bridgeHandler.updateSdkState(payload)
94
+ }
95
+
96
+ override fun passFcmPushToken(payload: String) {
97
+ bridgeHandler.passPushToken(payload)
98
+ }
99
+
100
+ override fun passFcmPushPayload(payload: String) {
101
+ bridgeHandler.passPushPayload(payload)
102
+ }
103
+
104
+ override fun passPushKitPushToken(payload: String) {
105
+ bridgeHandler.passPushToken(payload)
106
+ }
107
+
108
+ override fun onOrientationChanged() {
109
+ bridgeHandler.onOrientationChanged()
110
+ }
111
+
112
+ override fun pushPermissionResponseAndroid(payload: String) {
113
+ bridgeHandler.permissionResponse(payload)
114
+ }
115
+
116
+ override fun setupNotificationChannels() {
117
+ bridgeHandler.setupNotificationChannels()
118
+ }
119
+
120
+ override fun navigateToSettingsAndroid() {
121
+ bridgeHandler.navigateToSettings()
122
+ }
123
+
124
+ override fun requestPushPermissionAndroid() {
125
+ bridgeHandler.requestPushPermission()
126
+ }
127
+
128
+ override fun updatePushPermissionRequestCountAndroid(payload: String) {
129
+ bridgeHandler.updatePushPermissionRequestCount(payload)
130
+ }
131
+
132
+ override fun deviceIdentifierTrackingStatusUpdate(payload: String) {
133
+ bridgeHandler.deviceIdentifierTrackingStatusUpdate(payload)
134
+ }
135
+
136
+ override fun deleteUser(payload: String, promise: Promise) {
137
+ bridgeHandler.deleteUser(payload, promise)
138
+ }
139
+
140
+ override fun registerForPush() {
141
+ // iOS only
142
+ }
143
+ }