expo-helium 3.1.1 → 3.1.2
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/android/build.gradle
CHANGED
|
@@ -43,7 +43,7 @@ android {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
dependencies {
|
|
46
|
-
implementation("com.tryhelium.paywall:core:0.1.
|
|
46
|
+
implementation("com.tryhelium.paywall:core:0.1.15")
|
|
47
47
|
implementation("com.google.code.gson:gson:2.10.1")
|
|
48
48
|
implementation("com.android.billingclient:billing:8.0.0")
|
|
49
49
|
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
|
@@ -13,8 +13,8 @@ import com.google.gson.reflect.TypeToken
|
|
|
13
13
|
import com.tryhelium.paywall.core.Helium
|
|
14
14
|
import com.tryhelium.paywall.core.HeliumEnvironment
|
|
15
15
|
import com.tryhelium.paywall.core.event.HeliumEvent
|
|
16
|
+
import com.tryhelium.paywall.core.event.HeliumEventDictionaryMapper
|
|
16
17
|
import com.tryhelium.paywall.core.event.PaywallEventHandlers
|
|
17
|
-
import com.tryhelium.paywall.core.event.*
|
|
18
18
|
import com.tryhelium.paywall.core.HeliumFallbackConfig
|
|
19
19
|
import com.tryhelium.paywall.core.HeliumIdentityManager
|
|
20
20
|
import com.tryhelium.paywall.core.HeliumUserTraits
|
|
@@ -51,59 +51,6 @@ class HasEntitlementResult : Record {
|
|
|
51
51
|
var hasEntitlement: Boolean? = null
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
* Extension function to convert any object (especially HeliumEvent data classes) to a Map.
|
|
56
|
-
* Uses Kotlin reflection to extract all member properties from data classes.
|
|
57
|
-
*/
|
|
58
|
-
@Suppress("UNCHECKED_CAST")
|
|
59
|
-
private fun Any.toMap(): Map<String, Any?> {
|
|
60
|
-
return try {
|
|
61
|
-
val kClass = this::class
|
|
62
|
-
kClass.memberProperties.associate { prop ->
|
|
63
|
-
prop.isAccessible = true
|
|
64
|
-
val value = (prop as kotlin.reflect.KProperty1<Any, *>).get(this)
|
|
65
|
-
prop.name to when (value) {
|
|
66
|
-
is Enum<*> -> value.name
|
|
67
|
-
is List<*> -> value
|
|
68
|
-
is Map<*, *> -> value
|
|
69
|
-
else -> value
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
} catch (e: Exception) {
|
|
73
|
-
android.util.Log.e("HeliumPaywallSdk", "Failed to convert to map: ${e.message}", e)
|
|
74
|
-
emptyMap()
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Extracts the event type string from a HeliumEvent for JavaScript consumption.
|
|
80
|
-
* Maps Android SDK event class names to camelCase type strings expected by TypeScript.
|
|
81
|
-
*/
|
|
82
|
-
private fun getEventType(event: Any): String? {
|
|
83
|
-
return when (event) {
|
|
84
|
-
is PaywallOpen -> "paywallOpen"
|
|
85
|
-
is PaywallClose -> "paywallClose"
|
|
86
|
-
is PaywallDismissed -> "paywallDismissed"
|
|
87
|
-
is PaywallOpenFailed -> "paywallOpenFailed"
|
|
88
|
-
is PaywallSkipped -> "paywallSkipped"
|
|
89
|
-
is PaywallButtonPressed -> "paywallButtonPressed"
|
|
90
|
-
is ProductSelected -> "productSelected"
|
|
91
|
-
is PurchasedPressed -> "purchasePressed"
|
|
92
|
-
is PurchaseSucceeded -> "purchaseSucceeded"
|
|
93
|
-
is PurchaseCancelled -> "purchaseCancelled"
|
|
94
|
-
is PurchaseFailed -> "purchaseFailed"
|
|
95
|
-
is PurchaseRestored -> "purchaseRestored"
|
|
96
|
-
is PurchaseRestoreFailed -> "purchaseRestoreFailed"
|
|
97
|
-
is PurchasePending -> "purchasePending"
|
|
98
|
-
is PaywallsDownloadSuccess -> "paywallsDownloadSuccess"
|
|
99
|
-
is PaywallsDownloadError -> "paywallsDownloadError"
|
|
100
|
-
is PaywallWebViewRendered -> "paywallWebViewRendered"
|
|
101
|
-
is CustomPaywallAction -> "customPaywallAction"
|
|
102
|
-
//is UserAllocatedEvent -> "userAllocated"
|
|
103
|
-
else -> "unknown"
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
54
|
// Singleton to manage purchase state that survives module recreation in dev mode
|
|
108
55
|
private object NativeModuleManager {
|
|
109
56
|
// Always keep reference to the current module
|
|
@@ -183,17 +130,14 @@ class HeliumPaywallSdkModule : Module() {
|
|
|
183
130
|
}
|
|
184
131
|
|
|
185
132
|
// Event handler that converts events and adds backwards compatibility fields
|
|
186
|
-
val delegateEventHandler: (
|
|
187
|
-
val eventMap =
|
|
133
|
+
val delegateEventHandler: (HeliumEvent) -> Unit = { event ->
|
|
134
|
+
val eventMap = HeliumEventDictionaryMapper.toDictionary(event).toMutableMap()
|
|
188
135
|
// Add deprecated fields for backwards compatibility
|
|
189
136
|
eventMap["paywallName"]?.let { eventMap["paywallTemplateName"] = it }
|
|
190
137
|
eventMap["error"]?.let { eventMap["errorDescription"] = it }
|
|
191
138
|
eventMap["productId"]?.let { eventMap["productKey"] = it }
|
|
192
139
|
eventMap["buttonName"]?.let { eventMap["ctaName"] = it }
|
|
193
140
|
|
|
194
|
-
// Add event type for JavaScript consumption
|
|
195
|
-
getEventType(event)?.let { eventMap["type"] = it }
|
|
196
|
-
|
|
197
141
|
NativeModuleManager.currentModule?.sendEvent("onHeliumPaywallEvent", eventMap)
|
|
198
142
|
}
|
|
199
143
|
|
|
@@ -272,10 +216,8 @@ class HeliumPaywallSdkModule : Module() {
|
|
|
272
216
|
val convertedTraits = convertToHeliumUserTraits(customPaywallTraits)
|
|
273
217
|
|
|
274
218
|
// Helper to send event to JavaScript
|
|
275
|
-
val sendPaywallEvent: (
|
|
276
|
-
val eventMap =
|
|
277
|
-
// Add event type for JavaScript consumption
|
|
278
|
-
getEventType(event)?.let { eventMap["type"] = it }
|
|
219
|
+
val sendPaywallEvent: (HeliumEvent) -> Unit = { event ->
|
|
220
|
+
val eventMap = HeliumEventDictionaryMapper.toDictionary(event).toMutableMap()
|
|
279
221
|
NativeModuleManager.currentModule?.sendEvent("paywallEventHandlers", eventMap)
|
|
280
222
|
}
|
|
281
223
|
|
|
@@ -291,6 +233,7 @@ class HeliumPaywallSdkModule : Module() {
|
|
|
291
233
|
Helium.presentUpsell(
|
|
292
234
|
trigger = trigger,
|
|
293
235
|
dontShowIfAlreadyEntitled = dontShowIfAlreadyEntitled,
|
|
236
|
+
customPaywallTraits = convertedTraits,
|
|
294
237
|
eventListener = eventHandlers
|
|
295
238
|
)
|
|
296
239
|
}
|
|
@@ -546,7 +489,7 @@ class HeliumPaywallSdkModule : Module() {
|
|
|
546
489
|
} else {
|
|
547
490
|
null
|
|
548
491
|
}
|
|
549
|
-
}.toMap() as Map<String, HeliumFallbackConfig>
|
|
492
|
+
}.toMap() as? Map<String, HeliumFallbackConfig>
|
|
550
493
|
}
|
|
551
494
|
|
|
552
495
|
// Handle fallback bundle - write to helium_local directory where SDK expects it
|
|
@@ -588,7 +531,7 @@ class HeliumPaywallSdkModule : Module() {
|
|
|
588
531
|
*/
|
|
589
532
|
class CustomPaywallDelegate(
|
|
590
533
|
private val module: HeliumPaywallSdkModule,
|
|
591
|
-
private val eventHandler: (
|
|
534
|
+
private val eventHandler: (HeliumEvent) -> Unit
|
|
592
535
|
) : HeliumPaywallDelegate {
|
|
593
536
|
|
|
594
537
|
override fun onHeliumEvent(event: HeliumEvent) {
|
|
@@ -667,7 +610,7 @@ class CustomPaywallDelegate(
|
|
|
667
610
|
*/
|
|
668
611
|
class DefaultPaywallDelegate(
|
|
669
612
|
activity: Activity,
|
|
670
|
-
private val eventHandler: (
|
|
613
|
+
private val eventHandler: (HeliumEvent) -> Unit
|
|
671
614
|
) : PlayStorePaywallDelegate(activity) {
|
|
672
615
|
|
|
673
616
|
override fun onHeliumEvent(event: HeliumEvent) {
|