diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c17537..626b558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/react-native-superwall/releases) on GitHub. +## 1.4.3 + +### Enhancements + +- Upgrades Android SDK to 1.5.1 [View Android SDK release notes](https://github.com/superwall-me/Superwall-Android/releases/tag/1.5.1) +- Upgrades iOS SDK to 3.12.0 [View iOS SDK release notes](https://github.com/superwall-me/Superwall-iOS/releases/tag/3.12.0) + +### Fixes + +- Fixes issue where accessing configuration state before configuring would cause a crash. + ## 1.4.2 ### Fixes diff --git a/android/build.gradle b/android/build.gradle index c0fb913..046d7f2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ dependencies { implementation "com.facebook.react:react-native:+" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation "com.superwall.sdk:superwall-android:1.3.1" + implementation "com.superwall.sdk:superwall-android:1.5.1" implementation 'com.android.billingclient:billing:6.1.0' } diff --git a/android/src/main/java/com/superwallreactnative/SuperwallReactNativeModule.kt b/android/src/main/java/com/superwallreactnative/SuperwallReactNativeModule.kt index ee9298f..0fce10f 100644 --- a/android/src/main/java/com/superwallreactnative/SuperwallReactNativeModule.kt +++ b/android/src/main/java/com/superwallreactnative/SuperwallReactNativeModule.kt @@ -33,6 +33,8 @@ import com.superwallreactnative.models.toJson import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import kotlinx.coroutines.flow.first +import com.superwall.sdk.config.models.ConfigurationStatus class SuperwallReactNativeModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { @@ -187,7 +189,12 @@ class SuperwallReactNativeModule(private val reactContext: ReactApplicationConte @ReactMethod fun getConfigurationStatus(promise: Promise) { - promise.resolve(Superwall.instance.configurationState.asString()) + CoroutineScope(Dispatchers.IO).launch { + if(!Superwall.hasInitialized.first()) + promise.resolve(ConfigurationStatus.Pending.asString()) + else + promise.resolve(Superwall.instance.configurationState.asString()) + } } @ReactMethod @@ -253,14 +260,17 @@ class SuperwallReactNativeModule(private val reactContext: ReactApplicationConte @ReactMethod fun confirmAllAssignments(promise: Promise) { CoroutineScope(Dispatchers.IO).launch { - val result = Superwall.instance.confirmAllAssignments() - val array = Arguments.createArray() - result.forEach { assignment -> - array.pushMap(assignment.toJson()) - } - launch(Dispatchers.Main) { - promise.resolve(array) - } + Superwall.instance.confirmAllAssignments().fold({ + launch(Dispatchers.Main) { + val array = Arguments.createArray() + it.forEach { assignment -> + array.pushMap(assignment.toJson()) + } + promise.resolve(array) + } + },{ + promise.reject("Error", it.message) + }) } } @@ -271,10 +281,13 @@ class SuperwallReactNativeModule(private val reactContext: ReactApplicationConte promise: Promise ) { CoroutineScope(Dispatchers.IO).launch { - val result = Superwall.instance.getPresentationResult(event, params?.toHashMap()) - launch(Dispatchers.Main) { - promise.resolve(result.toJson()) - } + Superwall.instance.getPresentationResult(event, params?.toHashMap()).fold({ + launch(Dispatchers.Main) { + promise.resolve(it.toJson()) + } + },{ + promise.reject("Error", it.message) + }) } } diff --git a/android/src/main/java/com/superwallreactnative/bridges/SuperwallDelegateBridge.kt b/android/src/main/java/com/superwallreactnative/bridges/SuperwallDelegateBridge.kt index ebd8b4c..6833443 100644 --- a/android/src/main/java/com/superwallreactnative/bridges/SuperwallDelegateBridge.kt +++ b/android/src/main/java/com/superwallreactnative/bridges/SuperwallDelegateBridge.kt @@ -10,7 +10,7 @@ import com.superwall.sdk.paywall.presentation.PaywallInfo import com.superwallreactnative.models.SuperwallEvent import com.superwallreactnative.models.convertMapToReadableMap import com.superwallreactnative.models.toJson -import java.net.URL +import java.net.URI import android.net.Uri class SuperwallDelegateBridge( @@ -86,7 +86,7 @@ class SuperwallDelegateBridge( .emit("didPresentPaywall", data) } - override fun paywallWillOpenURL(url: URL) { + override fun paywallWillOpenURL(url: URI) { val data = Arguments.createMap().apply { putString("url", url.toString()) } diff --git a/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt b/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt index 3d8cdfc..2bd6d7f 100644 --- a/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt +++ b/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt @@ -190,15 +190,24 @@ class SuperwallEvent { map.putString("event", "paywallWebviewLoadFallback") map.putMap("paywallInfo", superwallEvent.paywallInfo.toJson()) } - is SuperwallEvent.ErrorThrown -> { - map.putString("event", "errorThrown") - } is SuperwallEvent.ConfigFail -> { map.putString("event", "configFail") } is SuperwallEvent.ConfirmAllAssignments -> { map.putString("event", "confirmAllAssignments") } + is SuperwallEvent.PaywallResourceLoadFail -> { + map.putString("event", "paywallResourceLoadFail") + map.putString("url", superwallEvent.url.toString()) + map.putString("error", superwallEvent.error) + } + is SuperwallEvent.ShimmerViewComplete -> { + map.putString("event", "shimmerViewComplete") + } + is SuperwallEvent.ShimmerViewStart -> { + map.putString("event", "shimmerViewStart") + } + else -> {} } return map } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 8b92ad2..b5add05 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1118,14 +1118,14 @@ PODS: - PurchasesHybridCommon (= 9.7.2) - React-Core - SocketRocket (0.6.1) - - Superscript (0.1.12) + - Superscript (0.1.16) - superwall-react-native (1.4.2): - glog - RCT-Folly (= 2022.05.16.00) - React-Core - - SuperwallKit (= 3.11.1) - - SuperwallKit (3.11.1): - - Superscript (= 0.1.12) + - SuperwallKit (= 3.12.0) + - SuperwallKit (3.12.0): + - Superscript (= 0.1.16) - Yoga (1.14.0) DEPENDENCIES: @@ -1392,9 +1392,9 @@ SPEC CHECKSUMS: RevenueCat: 7be0d7bde9efb2fc1ebd1888522c55bb4f9feb18 RNPurchases: 06957eb2f35bd7bb336d32fccf3534d45a3fda8a SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 - Superscript: 1ed1b4364f93bd16be05d085bba7357dbab95c83 - superwall-react-native: 9505d6e29c25c9d53f0e053545bad52a3081fc53 - SuperwallKit: ff739c94ebc351ae210c8b0f0b3931e930d74053 + Superscript: 17e2597de5e1ddfa132e217b33d1eb8eddf13e0f + superwall-react-native: 45c2c0e4a0b9599b008a1d7a6d1e7c66a129d2e0 + SuperwallKit: 9abe07053249c596af9875a3b857236068a79edc Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 PODFILE CHECKSUM: 76fced934770e056b70a3087a2bc377b3556bae1 diff --git a/ios/Json/SuperwallEventInfo+Json.swift b/ios/Json/SuperwallEventInfo+Json.swift index 8d01b34..2ffe2c0 100644 --- a/ios/Json/SuperwallEventInfo+Json.swift +++ b/ios/Json/SuperwallEventInfo+Json.swift @@ -138,6 +138,10 @@ extension SuperwallEvent { return ["event": "adServicesTokenRequestFail", "error": error.localizedDescription] case .adServicesTokenRequestComplete(token: let token): return ["event": "adServicesTokenRequestComplete", "token": token] + case .shimmerViewStart: + return ["event": "shimmerViewStart"] + case .shimmerViewComplete: + return ["event": "shimmerViewComplete"] } } } diff --git a/ios/Json/SuperwallOptions+Json.swift b/ios/Json/SuperwallOptions+Json.swift index 798e57b..787f03c 100644 --- a/ios/Json/SuperwallOptions+Json.swift +++ b/ios/Json/SuperwallOptions+Json.swift @@ -9,8 +9,7 @@ extension SuperwallOptions { let networkEnvironment = NetworkEnvironment.fromJson(networkEnvironmentValue), let isExternalDataCollectionEnabled = dictionary["isExternalDataCollectionEnabled"] as? Bool, let loggingValue = dictionary["logging"] as? [String: Any], - let logging = Logging.fromJson(loggingValue), - let collectAdServicesAttribution = dictionary["collectAdServicesAttribution"] as? Bool + let logging = Logging.fromJson(loggingValue) else { return nil } @@ -25,7 +24,6 @@ extension SuperwallOptions { superwallOptions.localeIdentifier = localeIdentifier superwallOptions.isGameControllerEnabled = isGameControllerEnabled superwallOptions.logging = logging - superwallOptions.collectAdServicesAttribution = collectAdServicesAttribution return superwallOptions } diff --git a/src/public/SuperwallEventInfo.ts b/src/public/SuperwallEventInfo.ts index 27d1a70..1f0eb50 100644 --- a/src/public/SuperwallEventInfo.ts +++ b/src/public/SuperwallEventInfo.ts @@ -78,6 +78,8 @@ export enum EventType { adServicesTokenRequestStart = "adServicesTokenRequestStart", adServicesTokenRequestFail = "adServicesTokenRequestFail", adServicesTokenRequestComplete = "adServicesTokenRequestComplete" + shimmerViewStart = "shimmerViewStart" + shimmerViewComplete = "shimmerViewComplete" } export class SuperwallEvent { @@ -151,6 +153,8 @@ export class SuperwallEvent { case EventType.adServicesTokenRequestStart: case EventType.errorThrown: case EventType.confirmAllAssignments: + case EventType.shimmerViewStart: + case EventType.shimmerViewComplete: return new SuperwallEvent({ type: eventType }); case EventType.restoreFail: return new SuperwallEvent({ diff --git a/superwall-react-native.podspec b/superwall-react-native.podspec index 01a4b87..2bf6b95 100644 --- a/superwall-react-native.podspec +++ b/superwall-react-native.podspec @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/superwall-me/Superwall-React-Native.git", :tag => "#{s.version}" } s.source_files = "ios/**/*.{h,m,mm,swift}" - s.dependency "SuperwallKit", '3.11.1' + s.dependency "SuperwallKit", '3.12.0' # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0. # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.