@customerglu/react-native-customerglu 3.0.0-beta-1.4 → 3.0.0-beta-1.6
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.
|
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
|
|
20
20
|
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
21
21
|
s.private_header_files = "ios/generated/**/*.h"
|
|
22
|
-
s.dependency "CustomerGlu", "3.0.
|
|
22
|
+
s.dependency "CustomerGlu", "3.0.13"
|
|
23
23
|
|
|
24
24
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
25
25
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
@@ -8,6 +8,7 @@ import android.content.Context
|
|
|
8
8
|
import android.content.Intent
|
|
9
9
|
import android.content.IntentFilter
|
|
10
10
|
import android.content.pm.PackageManager
|
|
11
|
+
import android.content.res.Resources
|
|
11
12
|
import android.os.Handler
|
|
12
13
|
import android.os.Looper
|
|
13
14
|
import android.util.Log
|
|
@@ -18,6 +19,7 @@ import com.customerglu.sdk.Modal.NudgeConfiguration
|
|
|
18
19
|
import com.customerglu.sdk.Utils.CGConstants
|
|
19
20
|
import com.customerglu.sdk.Utils.Comman
|
|
20
21
|
import com.customerglu.sdk.pip.PIPHelper
|
|
22
|
+
import com.facebook.react.bridge.Arguments
|
|
21
23
|
|
|
22
24
|
import com.facebook.react.bridge.Promise
|
|
23
25
|
import com.facebook.react.bridge.ReactMethod
|
|
@@ -119,17 +121,38 @@ class RncustomergluModule(reactContext: ReactApplicationContext) :
|
|
|
119
121
|
val data = intent.getStringExtra("data") ?: ""
|
|
120
122
|
Log.d(TAG, "Received broadcast event with data: $data")
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
try {
|
|
125
|
+
val jsonObject = JSONObject(data)
|
|
126
|
+
val screenHeight = Resources.getSystem().displayMetrics.heightPixels
|
|
127
|
+
val resultMap = Arguments.createMap()
|
|
128
|
+
|
|
129
|
+
jsonObject.keys().forEach { key ->
|
|
130
|
+
val percentageStr = jsonObject.optString(key, "0")
|
|
131
|
+
val percentage = percentageStr.toFloatOrNull()
|
|
132
|
+
|
|
133
|
+
if (percentage != null && percentage in 0f..100f) {
|
|
134
|
+
var pixelValue = (percentage / 100) * screenHeight
|
|
135
|
+
val density = Resources.getSystem().displayMetrics.density
|
|
136
|
+
pixelValue /= density
|
|
137
|
+
resultMap.putInt(key, pixelValue.toInt())
|
|
138
|
+
} else {
|
|
139
|
+
Log.e(TAG, "Invalid percentage value for key $key: $percentageStr")
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (resultMap.keySetIterator().hasNextKey()) {
|
|
144
|
+
sendEventToJs("CGBANNER_FINAL_HEIGHT", resultMap)
|
|
145
|
+
} else {
|
|
146
|
+
Log.w(TAG, "No valid banner heights to send.")
|
|
147
|
+
}
|
|
148
|
+
} catch (e: JSONException) {
|
|
149
|
+
Log.e(TAG, "Failed to parse JSON data: $e")
|
|
150
|
+
} catch (e: Exception) {
|
|
151
|
+
Log.e(TAG, "Unexpected error: $e")
|
|
127
152
|
}
|
|
128
|
-
|
|
129
|
-
// Send the event to JS
|
|
130
|
-
//sendEventToJs("onCustomerGluAnalyticsEvent", params)
|
|
131
153
|
}
|
|
132
154
|
|
|
155
|
+
|
|
133
156
|
if (intent.action == INVALID_CAMPAIGN_BROADCAST_ACTION) {
|
|
134
157
|
val data = intent.getStringExtra("data") ?: ""
|
|
135
158
|
Log.d(TAG, "Received broadcast event with data: $data")
|