Skip to content

Commit

Permalink
Adds dismiss to react native, upgrades android SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuftor committed Jul 24, 2024
1 parent 391ec6f commit d1b78a4
Show file tree
Hide file tree
Showing 14 changed files with 1,006 additions and 890 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.3

### Enhancements

- Adds `Superwall.shared.dismiss()` to be able to dismiss a paywall programmatically.
- Upgrades Android SDK to 1.2.1. [View Android SDK release notes](https://github.com/superwall-me/Superwall-Android/releases/tag/1.1.7)

## 1.2.2

### Enhancements
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.1.7"
implementation "com.superwall.sdk:superwall-android:1.2.1"
implementation 'com.android.billingclient:billing:6.1.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.superwall.sdk.identity.identify
import com.superwall.sdk.identity.setUserAttributes
import com.superwall.sdk.misc.ActivityProvider
import com.superwall.sdk.paywall.presentation.PaywallPresentationHandler
import com.superwall.sdk.paywall.presentation.dismiss
import com.superwall.sdk.paywall.presentation.register
import com.superwallreactnative.bridges.SuperwallDelegateBridge
import com.superwallreactnative.models.IdentityOptions
Expand All @@ -24,6 +25,9 @@ import com.superwallreactnative.models.SuperwallOptions
import com.superwallreactnative.models.convertMapToReadableMap
import com.superwallreactnative.models.convertReadableMapToMap
import com.superwallreactnative.models.toJson
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class SuperwallReactNativeModule(private val reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {
Expand Down Expand Up @@ -214,4 +218,12 @@ class SuperwallReactNativeModule(private val reactContext: ReactApplicationConte
val restorationResult = RestorationResult.fromJson(result)
purchaseController.restorePromise?.complete(restorationResult)
}

@ReactMethod
fun dismiss(promise: Promise) {
CoroutineScope(Dispatchers.Main).launch {
Superwall.instance.dismiss()
promise.resolve(null)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fun PaywallPresentationRequestStatusReason.toJson(): ReadableMap {
}
is PaywallPresentationRequestStatusReason.NoRuleMatch -> map.putString("reason", "noRuleMatch")
is PaywallPresentationRequestStatusReason.EventNotFound -> map.putString("reason", "eventNotFound")
is PaywallPresentationRequestStatusReason.NoPaywallViewController -> map.putString("reason", "noPaywallViewController")
is PaywallPresentationRequestStatusReason.NoPaywallView -> map.putString("reason", "noPaywallViewController")
is PaywallPresentationRequestStatusReason.NoPresenter -> map.putString("reason", "noPresenter")
is PaywallPresentationRequestStatusReason.NoConfig -> map.putString("reason", "noConfig")
is PaywallPresentationRequestStatusReason.SubscriptionStatusTimeout -> map.putString("reason", "subscriptionStatusTimeout")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ class SuperwallEvent {
val map = Arguments.createMap()
when (superwallEvent) {
is SuperwallEvent.FirstSeen -> map.putString("event", "firstSeen")
is SuperwallEvent.Reset -> map.putString("event", "reset")
is SuperwallEvent.Restore.Start -> map.putString("event", "restoreStart")
is SuperwallEvent.Restore.Complete -> map.putString("event", "restoreComplete")
is SuperwallEvent.ConfigRefresh -> map.putString("event", "configRefresh")
is SuperwallEvent.Restore.Fail -> {
map.putString("event", "restoreFail")
map.putString("message", superwallEvent.reason)
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ PODS:
- PurchasesHybridCommon (= 9.7.2)
- React-Core
- SocketRocket (0.6.1)
- superwall-react-native (1.2.1):
- superwall-react-native (1.2.3):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
Expand Down Expand Up @@ -1389,7 +1389,7 @@ SPEC CHECKSUMS:
RevenueCat: 7be0d7bde9efb2fc1ebd1888522c55bb4f9feb18
RNPurchases: 06957eb2f35bd7bb336d32fccf3534d45a3fda8a
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
superwall-react-native: 1030e20b03e7b856ae87afd89aa9fe4e7d9695ea
superwall-react-native: edd532239806122426597e03eef77dab8b3a180d
SuperwallKit: e6db6c60f6dc95c3dc841525f84dc8504cfffb5a
Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312

Expand Down
2 changes: 2 additions & 0 deletions ios/Json/SuperwallEventInfo+Json.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ extension SuperwallEvent {
switch self {
case .firstSeen:
return ["event": "firstSeen"]
case .reset:
return ["event": "reset"]
case .appOpen:
return ["event": "appOpen"]
case .appLaunch:
Expand Down
5 changes: 5 additions & 0 deletions ios/SuperwallReactNative.mm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ @interface RCT_EXTERN_MODULE(SuperwallReactNative, NSObject)

RCT_EXTERN_METHOD(didRestore:(NSDictionary *)result)

RCT_EXTERN_METHOD(
dismiss:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject
)

+ (BOOL)requiresMainQueueSetup
{
return NO;
Expand Down
12 changes: 11 additions & 1 deletion ios/SuperwallReactNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SuperwallReactNative: RCTEventEmitter {
resolve(nil)
}

Superwall.shared.setPlatformWrapper("React Native");
Superwall.shared.setPlatformWrapper("React Native")
}

@objc(identify:options:)
Expand Down Expand Up @@ -193,4 +193,14 @@ class SuperwallReactNative: RCTEventEmitter {
}
purchaseController.restoreCompletion?(restorationResult)
}

@objc(dismiss:withRejecter:)
func dismiss(
resolve: @escaping RCTPromiseResolveBlock,
reject: @escaping RCTPromiseRejectBlock
) {
Superwall.shared.dismiss {
resolve(nil)
}
}
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.2",
"version": "1.2.3",
"description": "The React Native package for Superwall",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
4 changes: 4 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,8 @@ export default class Superwall {
await this.awaitConfig();
await SuperwallReactNative.setUserAttributes(userAttributes);
}

async dismiss() {
await SuperwallReactNative.dismiss();
}
}
2 changes: 2 additions & 0 deletions src/public/SuperwallEventInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class SuperwallEventInfo {

export enum EventType {
firstSeen = "firstSeen",
configRefresh = "configRefresh",
appOpen = "appOpen",
appLaunch = "appLaunch",
identityAlias = "identityAlias",
Expand Down Expand Up @@ -117,6 +118,7 @@ export class SuperwallEvent {

// Example for one case, replicate logic for other cases as needed
switch (eventType) {
case EventType.configRefresh:
case EventType.firstSeen:
case EventType.appOpen:
case EventType.appLaunch:
Expand Down
Loading

0 comments on commit d1b78a4

Please sign in to comment.