From 7531a38be483c55b866bbdbd84ed37a86072b74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20To=CC=88r?= <3296904+yusuftor@users.noreply.github.com> Date: Thu, 22 Aug 2024 11:47:48 +0200 Subject: [PATCH] Update Android and iOS SDK --- CHANGELOG.md | 7 +++++++ android/build.gradle | 2 +- .../SuperwallReactNativeModule.kt | 7 ++++++- .../models/SuperwallEvent.kt | 16 ++++++++++++++++ example/ios/Podfile.lock | 8 ++++---- ios/Json/SuperwallEventInfo+Json.swift | 9 +++++++++ ios/SuperwallReactNative.mm | 1 + ios/SuperwallReactNative.swift | 5 +++-- package.json | 2 +- src/index.tsx | 4 +++- src/public/SuperwallEventInfo.ts | 16 +++++++++++++++- superwall-react-native.podspec | 2 +- 12 files changed, 67 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17856c8..602b358 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/react-native-superwall/releases) on GitHub. +## 1.2.6 + +### Enhancements + +- Upgrades iOS SDK to 3.7.3. [View iOS SDK release notes](https://github.com/superwall-me/Superwall-iOS/releases/tag/3.7.3) +- Upgrades Android SDK to 1.2.4. [View Android SDK release notes](https://github.com/superwall-me/Superwall-Android/releases/tag/1.2.4) + ## 1.2.5 ### Fixes diff --git a/android/build.gradle b/android/build.gradle index c9122cd..885917b 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.2.1" + implementation "com.superwall.sdk:superwall-android:1.2.4" 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 7c12800..2afd35f 100644 --- a/android/src/main/java/com/superwallreactnative/SuperwallReactNativeModule.kt +++ b/android/src/main/java/com/superwallreactnative/SuperwallReactNativeModule.kt @@ -12,6 +12,7 @@ import com.superwall.sdk.Superwall import com.superwall.sdk.identity.identify import com.superwall.sdk.identity.setUserAttributes import com.superwall.sdk.misc.ActivityProvider +import com.superwall.sdk.misc.sdkVersion import com.superwall.sdk.paywall.presentation.PaywallPresentationHandler import com.superwall.sdk.paywall.presentation.dismiss import com.superwall.sdk.paywall.presentation.register @@ -44,6 +45,7 @@ class SuperwallReactNativeModule(private val reactContext: ReactApplicationConte apiKey: String, options: ReadableMap? = null, usingPurchaseController: Boolean, + platformVersion: String, completion: Promise ) { val options = options?.let { @@ -73,7 +75,10 @@ class SuperwallReactNativeModule(private val reactContext: ReactApplicationConte ) } - Superwall.instance.setPlatformWrapper("React Native"); + Superwall.instance.setPlatformWrapper( + "React Native", + version = sdkVersion + ); } @ReactMethod diff --git a/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt b/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt index ecda32d..005f120 100644 --- a/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt +++ b/android/src/main/java/com/superwallreactnative/models/SuperwallEvent.kt @@ -177,6 +177,22 @@ class SuperwallEvent { is SuperwallEvent.SurveyClose -> { map.putString("event", "surveyClose") } + is SuperwallEvent.ConfigAttributes -> { + map.putString("event", "configAttributes") + } + is SuperwallEvent.CustomPlacement -> { + map.putString("event", "customPlacement") + map.putString("name", superwallEvent.placementName) + map.putMap("params", convertMapToReadableMap(superwallEvent.params)) + map.putMap("paywallInfo", superwallEvent.paywallInfo.toJson()) + } + is SuperwallEvent.PaywallWebviewLoadFallback -> { + map.putString("event", "paywallWebviewLoadFallback") + map.putMap("paywallInfo", superwallEvent.paywallInfo.toJson()) + } + is SuperwallEvent.ErrorThrown -> { + map.putString("event", "errorThrown") + } } return map } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 1c43174..fc3d0e3 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1122,8 +1122,8 @@ PODS: - glog - RCT-Folly (= 2022.05.16.00) - React-Core - - SuperwallKit (= 3.7.0) - - SuperwallKit (3.7.0) + - SuperwallKit (= 3.7.3) + - SuperwallKit (3.7.3) - Yoga (1.14.0) DEPENDENCIES: @@ -1389,8 +1389,8 @@ SPEC CHECKSUMS: RevenueCat: 7be0d7bde9efb2fc1ebd1888522c55bb4f9feb18 RNPurchases: 06957eb2f35bd7bb336d32fccf3534d45a3fda8a SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 - superwall-react-native: 7608d6b28032a2fec4757df086fdbbe41d6d7d0d - SuperwallKit: 5db90223421220fb745a7a9814c684a3a71f7449 + superwall-react-native: dbe9dad5ca0313b7092017d2683d5a22ca07354a + SuperwallKit: 3ff5d6783715428752d2bff9580897f2c74f7b2c Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 PODFILE CHECKSUM: 76fced934770e056b70a3087a2bc377b3556bae1 diff --git a/ios/Json/SuperwallEventInfo+Json.swift b/ios/Json/SuperwallEventInfo+Json.swift index 01ebb93..8a79e49 100644 --- a/ios/Json/SuperwallEventInfo+Json.swift +++ b/ios/Json/SuperwallEventInfo+Json.swift @@ -119,6 +119,15 @@ extension SuperwallEvent { return ["event": "restoreComplete"] case .restoreFail(message: let message): return ["event": "restoreFail", "message": message] + case .customPlacement(name: let name, params: let params, paywallInfo: let paywallInfo): + return [ + "event": "customPlacement", + "name": name, + "params": params, + "paywallInfo": paywallInfo.toJson() + ] + case .configAttributes: + return ["event": "configAttributes"] } } } diff --git a/ios/SuperwallReactNative.mm b/ios/SuperwallReactNative.mm index 4201366..744bc6f 100644 --- a/ios/SuperwallReactNative.mm +++ b/ios/SuperwallReactNative.mm @@ -6,6 +6,7 @@ @interface RCT_EXTERN_MODULE(SuperwallReactNative, NSObject) configure:(NSString *)apiKey options:(NSDictionary *)options usingPurchaseController:(BOOL)usingPurchaseController + sdkVersion:(NSString *)sdkVersion withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject ) diff --git a/ios/SuperwallReactNative.swift b/ios/SuperwallReactNative.swift index 3817465..c29a5df 100644 --- a/ios/SuperwallReactNative.swift +++ b/ios/SuperwallReactNative.swift @@ -29,11 +29,12 @@ class SuperwallReactNative: RCTEventEmitter { ] } - @objc(configure:options:usingPurchaseController:withResolver:withRejecter:) + @objc(configure:options:usingPurchaseController:sdkVersion:withResolver:withRejecter:) func configure( apiKey: String, options: [String: Any]?, usingPurchaseController: Bool, + sdkVersion: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock ) { @@ -51,7 +52,7 @@ class SuperwallReactNative: RCTEventEmitter { resolve(nil) } - Superwall.shared.setPlatformWrapper("React Native") + Superwall.shared.setPlatformWrapper("React Native", version: sdkVersion) } @objc(identify:options:) diff --git a/package.json b/package.json index b24d51f..f2115e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@superwall/react-native-superwall", - "version": "1.2.5", + "version": "1.2.6", "description": "The React Native package for Superwall", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/src/index.tsx b/src/index.tsx index 3f25aac..3517691 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -10,6 +10,7 @@ import { SuperwallEventInfo } from './public/SuperwallEventInfo'; import { NativeEventEmitter } from 'react-native'; import { IdentityOptions } from './public/IdentityOptions'; import { EventEmitter } from 'events'; +const { version } = require('../package.json'); const LINKING_ERROR = `The package 'superwall-react-native' doesn't seem to be linked. Make sure: \n\n` + @@ -255,7 +256,8 @@ export default class Superwall { await SuperwallReactNative.configure( apiKey, options?.toJson(), - !!purchaseController + !!purchaseController, + version ).then(() => { if (completion) completion(); }); diff --git a/src/public/SuperwallEventInfo.ts b/src/public/SuperwallEventInfo.ts index c8b462c..15386ad 100644 --- a/src/public/SuperwallEventInfo.ts +++ b/src/public/SuperwallEventInfo.ts @@ -69,7 +69,10 @@ export enum EventType { reset = "reset", restoreStart = "restoreStart", restoreComplete = "restoreComplete", - restoreFail = "restoreFail" + restoreFail = "restoreFail", + configAttributes = "configAttributes", + customPlacement = "customPlacement", + errorThrown = "errorThrown" } export class SuperwallEvent { @@ -112,6 +115,8 @@ export class SuperwallEvent { restoreType?: RestoreType; userAttributes?: Record; attempt?: number; + name?: string; + params?: Record; }) { Object.assign(this, options); } @@ -135,6 +140,8 @@ export class SuperwallEvent { case EventType.reset: case EventType.restoreStart: case EventType.restoreComplete: + case EventType.configAttributes: + case EventType.errorThrown: return new SuperwallEvent({ type: eventType }); case EventType.restoreFail: return new SuperwallEvent({ @@ -244,6 +251,13 @@ export class SuperwallEvent { ? PaywallPresentationRequestStatusReason.fromJson(json.reason) : undefined, }); + case EventType.customPlacement: + return new SuperwallEvent({ + type: eventType, + name: json.name, + params: json.params, + paywallInfo: PaywallInfo.fromJson(json.paywallInfo), + }); // Further cases would follow a similar pattern, handling additional properties as needed // For complex nested objects like 'result', 'paywallInfo', etc., you would use the corresponding fromJson methods default: diff --git a/superwall-react-native.podspec b/superwall-react-native.podspec index f254acc..6f07048 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.7.0' + s.dependency "SuperwallKit", '3.7.3' # 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.