Skip to content

Commit fbf9ec1

Browse files
Merge pull request #74 from apphud/placements_support
added placements support, refactored event emitter
2 parents 499736d + 412d6e8 commit fbf9ec1

35 files changed

+2668
-1456
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
137137
dependencies {
138138
// noinspection GradleDynamicVersion
139139
api 'com.facebook.react:react-native:+'
140-
implementation 'com.apphud:ApphudSDK-Android:2.8.4'
140+
implementation 'com.apphud:ApphudSDK-Android:2.9.1'
141141
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
142142
implementation 'com.android.billingclient:billing:7.1.1'
143143
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.reactnativeapphudsdk
2+
3+
import com.apphud.sdk.ApphudAttributionData
4+
import com.apphud.sdk.ApphudAttributionProvider
5+
import com.facebook.react.bridge.ReadableMap
6+
7+
internal data class AttributionParams(
8+
val identifier: String?,
9+
val provider: ApphudAttributionProvider,
10+
val data: ApphudAttributionData
11+
)
12+
13+
private fun Map<String, Any?>.removeNullableValues(): Map<String, Any> {
14+
val map = mutableMapOf<String, Any>()
15+
16+
for (pair in this) {
17+
pair.value?.let {
18+
map[pair.key] = it
19+
}
20+
}
21+
22+
return map
23+
}
24+
25+
internal fun ReadableMap.getAttributionParams(): AttributionParams? {
26+
val identifier = getString("identifier")
27+
28+
val provider = getString("attributionProviderId")?.let { attributionProviderId ->
29+
ApphudAttributionProvider.entries.find {
30+
it.value == attributionProviderId
31+
}
32+
} ?: return null
33+
34+
val data = getMap("data") ?: return null
35+
36+
val rawData = data
37+
.getMap("rawData")
38+
?.toHashMap()
39+
?.toMap()
40+
?.removeNullableValues() ?: emptyMap()
41+
42+
return AttributionParams(
43+
identifier = identifier,
44+
provider = provider,
45+
data = ApphudAttributionData(
46+
rawData = rawData,
47+
adNetwork = data.getString("adNetwork"),
48+
channel = data.getString("channel"),
49+
campaign = data.getString("campaign"),
50+
adSet = data.getString("adSet"),
51+
creative = data.getString("creative"),
52+
keyword = data.getString("keyword"),
53+
custom1 = data.getString("custom1"),
54+
custom2 = data.getString("custom2")
55+
)
56+
)
57+
}

0 commit comments

Comments
 (0)