Skip to content

Commit

Permalink
Merge pull request #27 from superwall/develop
Browse files Browse the repository at this point in the history
1.4.2
  • Loading branch information
yusuftor authored Nov 24, 2024
2 parents 625f45f + 153339c commit 0eb1d7b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 25 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/react-native-superwall/releases) on GitHub.

## 1.4.2

### Fixes

- Fixes an issue where params that were passed with `getPresentationResult(event:params:)` were being dropped.

## 1.4.1

### Enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import com.superwallreactnative.models.SuperwallOptions
import com.superwallreactnative.models.convertMapToReadableMap
import com.superwallreactnative.models.convertReadableMapToMap
import com.superwallreactnative.models.asString
import com.superwallreactnative.models.convertReadableMapToCompactMap
import com.superwallreactnative.models.toJson
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -272,8 +271,7 @@ class SuperwallReactNativeModule(private val reactContext: ReactApplicationConte
promise: Promise
) {
CoroutineScope(Dispatchers.IO).launch {
val paramsMap = params?.let { convertReadableMapToCompactMap(it) }
val result = Superwall.instance.getPresentationResult(event, paramsMap)
val result = Superwall.instance.getPresentationResult(event, params?.toHashMap())
launch(Dispatchers.Main) {
promise.resolve(result.toJson())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,3 @@ fun convertReadableMapToMap(readableMap: ReadableMap): Map<String, Any?> {
}
return map
}

fun convertReadableMapToCompactMap(readableMap: ReadableMap): Map<String, Any> {
val map: MutableMap<String, Any> = HashMap()
val iterator = readableMap.keySetIterator()
while (iterator.hasNextKey()) {
val key = iterator.nextKey()
when (val value = readableMap.getType(key)) {
ReadableType.String -> map[key] = readableMap.getString(key) ?: continue
ReadableType.Boolean -> map[key] = readableMap.getBoolean(key)
ReadableType.Number -> map[key] = readableMap.getDouble(key)
ReadableType.Map -> map[key] = convertReadableMapToMap(readableMap.getMap(key)!!)
ReadableType.Null -> continue
else -> {}
}
}
return map
}
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ PODS:
- React-Core
- SocketRocket (0.6.1)
- Superscript (0.1.12)
- superwall-react-native (1.4.1):
- superwall-react-native (1.4.2):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
Expand Down Expand Up @@ -1393,7 +1393,7 @@ SPEC CHECKSUMS:
RNPurchases: 06957eb2f35bd7bb336d32fccf3534d45a3fda8a
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Superscript: 1ed1b4364f93bd16be05d085bba7357dbab95c83
superwall-react-native: 6c5401f69c3185053bff9f09bfc52a2b97313eab
superwall-react-native: 9505d6e29c25c9d53f0e053545bad52a3081fc53
SuperwallKit: ff739c94ebc351ae210c8b0f0b3931e930d74053
Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312

Expand Down
2 changes: 1 addition & 1 deletion ios/SuperwallReactNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class SuperwallReactNative: RCTEventEmitter {
@objc(getPresentationResult:params:withResolver:withRejecter:)
func getPresentationResult(
event: String,
params: [String: Any],
params: [String: Any]?,
resolve: @escaping RCTPromiseResolveBlock,
reject: @escaping RCTPromiseRejectBlock
) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superwall/react-native-superwall",
"version": "1.4.1",
"version": "1.4.2",
"description": "The React Native package for Superwall",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
9 changes: 8 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,14 @@ export default class Superwall {
params?: Map<String, any>
): Promise<PresentationResult> {
await this.awaitConfig();
return await SuperwallReactNative.getPresentationResult(event, params);
let paramsObject = {};
if (params) {
paramsObject = Object.fromEntries(params);
}
return await SuperwallReactNative.getPresentationResult(
event,
paramsObject
);
}

async getConfigurationStatus(): Promise<ConfigurationStatus> {
Expand Down

0 comments on commit 0eb1d7b

Please sign in to comment.