@@ -17,7 +17,9 @@ import com.mparticle.internal.Logger
17
17
import com.mparticle.kits.KitIntegration.CommerceListener
18
18
import com.mparticle.kits.KitIntegration.IdentityListener
19
19
import com.mparticle.kits.KitIntegration.RoktListener
20
+ import com.mparticle.rokt.RoktConfig
20
21
import com.mparticle.rokt.RoktEmbeddedView
22
+ import com.rokt.roktsdk.CacheConfig
21
23
import com.rokt.roktsdk.Rokt
22
24
import com.rokt.roktsdk.Rokt.SdkFrameworkType.*
23
25
import com.rokt.roktsdk.RoktWidgetDimensionCallBack
@@ -141,7 +143,8 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
141
143
mpRoktEventCallback : MParticle .MpRoktEventCallback ? ,
142
144
placeHolders : MutableMap <String , WeakReference <RoktEmbeddedView >>? ,
143
145
fontTypefaces : MutableMap <String , WeakReference <Typeface >>? ,
144
- filterUser : FilteredMParticleUser ?
146
+ filterUser : FilteredMParticleUser ? ,
147
+ mpRoktConfig : RoktConfig ?
145
148
) {
146
149
val placeholders: Map <String , WeakReference <Widget >>? = placeHolders?.mapNotNull { entry ->
147
150
val widget = Widget (entry.value.get()?.context as Context )
@@ -186,14 +189,15 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
186
189
attributes?.get(SANDBOX_MODE_ROKT )?.let { value ->
187
190
finalAttributes.put(SANDBOX_MODE_ROKT , value)
188
191
}
189
-
192
+ val roktConfig = mpRoktConfig?. let { mapToRoktConfig(it) }
190
193
Rokt .execute(
191
194
viewName,
192
195
finalAttributes,
193
196
this ,
194
197
// Pass placeholders and fontTypefaces only if they are not empty or null
195
198
placeholders.takeIf { it?.isNotEmpty() == true },
196
- fontTypefaces.takeIf { it?.isNotEmpty() == true }
199
+ fontTypefaces.takeIf { it?.isNotEmpty() == true },
200
+ roktConfig
197
201
)
198
202
}
199
203
@@ -207,6 +211,33 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
207
211
Rokt .setFrameworkType(sdkFrameworkType)
208
212
}
209
213
214
+ public fun mapToRoktConfig (config : RoktConfig ): com.rokt.roktsdk.RoktConfig {
215
+ val colorMode = when (config.colorMode) {
216
+ RoktConfig .ColorMode .LIGHT -> com.rokt.roktsdk.RoktConfig .ColorMode .LIGHT
217
+ RoktConfig .ColorMode .DARK -> com.rokt.roktsdk.RoktConfig .ColorMode .DARK
218
+ RoktConfig .ColorMode .SYSTEM -> com.rokt.roktsdk.RoktConfig .ColorMode .SYSTEM
219
+ else -> com.rokt.roktsdk.RoktConfig .ColorMode .SYSTEM
220
+ }
221
+
222
+ val cacheConfig = config.cacheConfig?.cacheDurationInSeconds?.let {
223
+ CacheConfig (
224
+ cacheDurationInSeconds = it,
225
+ cacheAttributes = config.cacheConfig?.cacheAttributes
226
+ )
227
+ }
228
+
229
+ val edgeToEdgeDisplay = config.edgeToEdgeDisplay
230
+
231
+ val builder = com.rokt.roktsdk.RoktConfig .Builder ()
232
+ .colorMode(colorMode)
233
+ .edgeToEdgeDisplay(edgeToEdgeDisplay)
234
+
235
+ cacheConfig?.let {
236
+ builder.cacheConfig(it)
237
+ }
238
+ return builder.build()
239
+ }
240
+
210
241
private fun addIdentityAttributes (attributes : MutableMap <String , String >? , filterUser : FilteredMParticleUser ? ): MutableMap <String , String > {
211
242
val identityAttributes = mutableMapOf<String , String >()
212
243
if (filterUser != null ) {
0 commit comments