@usercentrics/react-native-sdk 2.2.1 → 2.2.2-RC1

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.
@@ -2,10 +2,7 @@ package com.usercentrics.reactnativemodule
2
2
 
3
3
  import androidx.test.ext.junit.runners.AndroidJUnit4
4
4
  import androidx.test.platform.app.InstrumentationRegistry
5
- import com.facebook.react.bridge.JavaOnlyMap
6
- import com.facebook.react.bridge.ReactApplicationContext
7
- import com.facebook.react.bridge.WritableArray
8
- import com.facebook.react.bridge.WritableMap
5
+ import com.facebook.react.bridge.*
9
6
  import com.facebook.soloader.SoLoader
10
7
  import com.usercentrics.reactnativemodule.api.FakeUsercentricsProxy
11
8
  import com.usercentrics.reactnativemodule.fake.FakePromise
@@ -699,31 +696,4 @@ class RNUsercentricsModuleTest {
699
696
 
700
697
  assertEquals(1, usercentricsProxy.resetCount)
701
698
  }
702
-
703
- @Test
704
- fun testShowFirstLayer() {
705
- val usercentricsProxy = FakeUsercentricsProxy()
706
- val contextMock = mockk<ReactApplicationContext>(relaxed = true)
707
- val module = RNUsercentricsModule(contextMock, usercentricsProxy)
708
-
709
- val promise = FakePromise()
710
- module.showFirstLayer(ShowFirstLayerMock.arguments, promise)
711
-
712
- assertEquals(
713
- FirstLayerStyleSettings(
714
- title = TitleSettings(alignment = SectionAlignment.END),
715
- message = MessageSettings(alignment = SectionAlignment.CENTER),
716
- cornerRadius = 50
717
- ),
718
- usercentricsProxy.showFirstLayerStyle
719
- )
720
- assertEquals(
721
- BannerSettings(font = null, logo = null),
722
- usercentricsProxy.showFirstLayerBannerSettings
723
- )
724
- assertEquals(
725
- UsercentricsLayout.Popup(PopupPosition.CENTER),
726
- usercentricsProxy.showFirstLayerLayout
727
- )
728
- }
729
699
  }
@@ -74,42 +74,50 @@ internal class RNUsercentricsModule(
74
74
 
75
75
  @ReactMethod
76
76
  fun showFirstLayer(options: ReadableMap, promise: Promise) {
77
- try {
78
- val assetManager = currentActivity!!.assets
79
-
80
- val layout = options.getString("layout")!!.usercentricsLayoutFromEnumString()
81
- val bannerSettings = options.getMap("bannerSettings")?.bannerSettingsFromMap(assetManager)
82
- val styleSettings = options.getMap("styleSettings")?.firstLayerStyleSettingsFromMap(assetManager)
83
-
84
- usercentricsProxy.showFirstLayer(
85
- currentActivity!!,
86
- layout,
87
- bannerSettings,
88
- styleSettings,
89
- promise
90
- )
91
-
92
- } catch (e: Exception) {
93
- promise.reject(e)
77
+ UiThreadUtil.runOnUiThread {
78
+ try {
79
+ val assetManager = currentActivity!!.assets
80
+
81
+ val layout = options.getString("layout")!!.usercentricsLayoutFromEnumString()
82
+ val bannerSettings =
83
+ options.getMap("bannerSettings")?.bannerSettingsFromMap(assetManager)
84
+ val styleSettings =
85
+ options.getMap("styleSettings")?.firstLayerStyleSettingsFromMap(assetManager)
86
+
87
+ usercentricsProxy.showFirstLayer(
88
+ currentActivity!!,
89
+ layout,
90
+ bannerSettings,
91
+ styleSettings,
92
+ promise
93
+ )
94
+
95
+ } catch (e: Exception) {
96
+ promise.reject(e)
97
+ }
94
98
  }
95
99
  }
96
100
 
97
101
  @ReactMethod
98
102
  fun showSecondLayer(options: ReadableMap, promise: Promise) {
99
- try {
100
- val assetManager = currentActivity!!.assets
103
+ UiThreadUtil.runOnUiThread {
104
+ try {
105
+ val assetManager = currentActivity!!.assets
106
+
107
+ val bannerSettings =
108
+ options.getMap("bannerSettings")?.bannerSettingsFromMap(assetManager)
109
+ val showCloseButton = options.getBoolean("showCloseButton")
110
+
101
111
 
102
- val bannerSettings =
103
- options.getMap("bannerSettings")?.bannerSettingsFromMap(assetManager)
104
- val showCloseButton = options.getBoolean("showCloseButton")
112
+ UsercentricsBanner(currentActivity!!, bannerSettings).showSecondLayer(
113
+ showCloseButton
114
+ ) {
115
+ promise.resolve(it?.toWritableMap())
116
+ }
105
117
 
106
- UsercentricsBanner(currentActivity!!, bannerSettings).showSecondLayer(
107
- showCloseButton
108
- ) {
109
- promise.resolve(it?.toWritableMap())
118
+ } catch (e: Exception) {
119
+ promise.reject(e)
110
120
  }
111
- } catch (e: Exception) {
112
- promise.reject(e)
113
121
  }
114
122
  }
115
123
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usercentrics/react-native-sdk",
3
- "version": "2.2.1",
3
+ "version": "2.2.2-RC1",
4
4
  "description": "Usercentrics SDK",
5
5
  "homepage": "https://usercentrics.com",
6
6
  "main": "lib/index.js",