Skip to content

Commit

Permalink
Update Android and iOS SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuftor committed Aug 22, 2024
1 parent 3d8c2d7 commit 7531a38
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -73,7 +75,10 @@ class SuperwallReactNativeModule(private val reactContext: ReactApplicationConte
)
}

Superwall.instance.setPlatformWrapper("React Native");
Superwall.instance.setPlatformWrapper(
"React Native",
version = sdkVersion
);
}

@ReactMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions ios/Json/SuperwallEventInfo+Json.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
}
}
1 change: 1 addition & 0 deletions ios/SuperwallReactNative.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
5 changes: 3 additions & 2 deletions ios/SuperwallReactNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand All @@ -51,7 +52,7 @@ class SuperwallReactNative: RCTEventEmitter {
resolve(nil)
}

Superwall.shared.setPlatformWrapper("React Native")
Superwall.shared.setPlatformWrapper("React Native", version: sdkVersion)
}

@objc(identify:options:)
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.2.5",
"version": "1.2.6",
"description": "The React Native package for Superwall",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
4 changes: 3 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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` +
Expand Down Expand Up @@ -255,7 +256,8 @@ export default class Superwall {
await SuperwallReactNative.configure(
apiKey,
options?.toJson(),
!!purchaseController
!!purchaseController,
version
).then(() => {
if (completion) completion();
});
Expand Down
16 changes: 15 additions & 1 deletion src/public/SuperwallEventInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -112,6 +115,8 @@ export class SuperwallEvent {
restoreType?: RestoreType;
userAttributes?: Record<string, any>;
attempt?: number;
name?: string;
params?: Record<string, any>;
}) {
Object.assign(this, options);
}
Expand All @@ -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({
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion superwall-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7531a38

Please sign in to comment.