react-native-purchases-ui 7.16.1 → 7.17.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,6 @@ Pod::Spec.new do |spec|
17
17
  spec.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
18
18
 
19
19
  spec.dependency "React-Core"
20
- spec.dependency "PurchasesHybridCommon", '8.11.2'
20
+ spec.dependency "PurchasesHybridCommonUI", '9.2.0'
21
21
  spec.swift_version = '5.7'
22
22
  end
@@ -59,7 +59,7 @@ android {
59
59
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
60
60
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
61
61
  versionCode 1
62
- versionName '7.16.1'
62
+ versionName '7.17.1'
63
63
  }
64
64
 
65
65
  buildTypes {
@@ -91,7 +91,7 @@ dependencies {
91
91
  //noinspection GradleDynamicVersion
92
92
  implementation "com.facebook.react:react-native:+"
93
93
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
94
- implementation 'com.revenuecat.purchases:purchases-hybrid-common-ui:8.11.2'
94
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common-ui:9.2.0'
95
95
  implementation 'androidx.compose.ui:ui-android:1.5.4'
96
96
  implementation "androidx.appcompat:appcompat:1.6.1"
97
97
  }
@@ -8,6 +8,8 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
8
8
  import com.facebook.react.bridge.ReactMethod
9
9
  import com.facebook.react.bridge.ReadableMap
10
10
  import com.revenuecat.purchases.hybridcommon.ui.PaywallResultListener
11
+ import com.revenuecat.purchases.hybridcommon.ui.PaywallSource
12
+ import com.revenuecat.purchases.hybridcommon.ui.PresentPaywallOptions
11
13
  import com.revenuecat.purchases.hybridcommon.ui.presentPaywallFromFragment
12
14
 
13
15
  internal class RNPaywallsModule(reactContext: ReactApplicationContext) :
@@ -33,13 +35,10 @@ internal class RNPaywallsModule(reactContext: ReactApplicationContext) :
33
35
 
34
36
  @ReactMethod
35
37
  fun presentPaywall(
36
- options: ReadableMap,
38
+ offeringIdentifier: String?,
39
+ displayCloseButton: Boolean?,
37
40
  promise: Promise
38
41
  ) {
39
- val hashMap = options.toHashMap()
40
- val offeringIdentifier = hashMap["offeringIdentifier"] as String?
41
- val displayCloseButton = hashMap["displayCloseButton"] as Boolean?
42
-
43
42
  presentPaywall(
44
43
  null,
45
44
  offeringIdentifier,
@@ -50,14 +49,11 @@ internal class RNPaywallsModule(reactContext: ReactApplicationContext) :
50
49
 
51
50
  @ReactMethod
52
51
  fun presentPaywallIfNeeded(
53
- options: ReadableMap,
52
+ requiredEntitlementIdentifier: String,
53
+ offeringIdentifier: String?,
54
+ displayCloseButton: Boolean,
54
55
  promise: Promise
55
56
  ) {
56
- val hashMap = options.toHashMap()
57
- val requiredEntitlementIdentifier = hashMap["requiredEntitlementIdentifier"] as String?
58
- val offeringIdentifier = hashMap["offeringIdentifier"] as String?
59
- val displayCloseButton = hashMap["displayCloseButton"] as Boolean?
60
-
61
57
  presentPaywall(
62
58
  requiredEntitlementIdentifier,
63
59
  offeringIdentifier,
@@ -74,16 +70,20 @@ internal class RNPaywallsModule(reactContext: ReactApplicationContext) :
74
70
  ) {
75
71
  val fragment = currentActivityFragment ?: return
76
72
 
77
- // TODO wire offeringIdentifier
78
73
  presentPaywallFromFragment(
79
74
  fragment = fragment,
80
- requiredEntitlementIdentifier = requiredEntitlementIdentifier,
81
- shouldDisplayDismissButton = displayCloseButton,
82
- paywallResultListener = object : PaywallResultListener {
83
- override fun onPaywallResult(paywallResult: String) {
84
- promise.resolve(paywallResult)
75
+ PresentPaywallOptions(
76
+ requiredEntitlementIdentifier = requiredEntitlementIdentifier,
77
+ shouldDisplayDismissButton = displayCloseButton,
78
+ paywallSource = offeringIdentifier?.let {
79
+ PaywallSource.OfferingIdentifier(it)
80
+ } ?: PaywallSource.DefaultOffering,
81
+ paywallResultListener = object : PaywallResultListener {
82
+ override fun onPaywallResult(paywallResult: String) {
83
+ promise.resolve(paywallResult)
84
+ }
85
85
  }
86
- }
86
+ )
87
87
  )
88
88
  }
89
89
  }
@@ -7,7 +7,10 @@
7
7
  //
8
8
 
9
9
  #import "PaywallViewManager.h"
10
- @import PurchasesHybridCommon;
10
+ #import "PaywallViewWrapper.h"
11
+
12
+ @import PurchasesHybridCommonUI;
13
+ @import RevenueCatUI;
11
14
 
12
15
  @implementation PaywallViewManager
13
16
 
@@ -17,7 +20,8 @@ RCT_EXPORT_MODULE(Paywall)
17
20
  {
18
21
  if (@available(iOS 15.0, *)) {
19
22
  PaywallProxy *proxy = [[PaywallProxy alloc] init];
20
- return [proxy createPaywallView].view;
23
+
24
+ return [[PaywallViewWrapper alloc] initWithPaywallViewController:[proxy createPaywallView]];
21
25
  } else {
22
26
  NSLog(@"Error: attempted to present paywalls on unsupported iOS version.");
23
27
  return nil;
@@ -0,0 +1,21 @@
1
+ //
2
+ // PaywallViewWrapper.h
3
+ // RNPaywalls
4
+ //
5
+ // Created by Nacho Soto on 1/23/24.
6
+ //
7
+
8
+ #import <UIKit/UIKit.h>
9
+
10
+ NS_ASSUME_NONNULL_BEGIN
11
+
12
+ @interface PaywallViewWrapper : UIView
13
+
14
+ - (instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE;
15
+ - (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
16
+
17
+ - (instancetype)initWithPaywallViewController:(UIViewController *)paywallViewController NS_DESIGNATED_INITIALIZER;
18
+
19
+ @end
20
+
21
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,61 @@
1
+ //
2
+ // PaywallViewWrapper.m
3
+ // RNPaywalls
4
+ //
5
+ // Created by Nacho Soto on 1/23/24.
6
+ //
7
+
8
+ #import "PaywallViewWrapper.h"
9
+
10
+ #import "UIView+Extensions.h"
11
+
12
+ @import PurchasesHybridCommonUI;
13
+ @import RevenueCatUI;
14
+
15
+ @interface PaywallViewWrapper () <RCPaywallViewControllerDelegate>
16
+
17
+ @property (strong, nonatomic) UIViewController *paywallViewController;
18
+
19
+ @property (nonatomic) BOOL addedToHierarchy;
20
+
21
+ @end
22
+
23
+ @implementation PaywallViewWrapper
24
+
25
+ - (instancetype)initWithPaywallViewController:(UIViewController *)paywallViewController {
26
+ NSParameterAssert(paywallViewController);
27
+
28
+ if ((self = [super initWithFrame:paywallViewController.view.bounds])) {
29
+ _paywallViewController = paywallViewController;
30
+ }
31
+
32
+ return self;
33
+ }
34
+
35
+ - (void)layoutSubviews {
36
+ [super layoutSubviews];
37
+
38
+ // Need to wait for this view to be in the hierarchy to look for the parent UIVC.
39
+ // This is required to add a SwiftUI `UIHostingController` to the hierarchy in a way that allows
40
+ // UIKit to read properties from the environment, like traits and safe area.
41
+ if (!self.addedToHierarchy) {
42
+ UIViewController *parentController = self.parentViewController;
43
+ if (parentController) {
44
+ self.paywallViewController.view.translatesAutoresizingMaskIntoConstraints = NO;
45
+ [parentController addChildViewController:self.paywallViewController];
46
+ [self addSubview:self.paywallViewController.view];
47
+ [self.paywallViewController didMoveToParentViewController:parentController];
48
+
49
+ [NSLayoutConstraint activateConstraints:@[
50
+ [self.paywallViewController.view.topAnchor constraintEqualToAnchor:self.topAnchor],
51
+ [self.paywallViewController.view.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
52
+ [self.paywallViewController.view.leftAnchor constraintEqualToAnchor:self.leftAnchor],
53
+ [self.paywallViewController.view.rightAnchor constraintEqualToAnchor:self.rightAnchor]
54
+ ]];
55
+
56
+ self.addedToHierarchy = YES;
57
+ }
58
+ }
59
+ }
60
+
61
+ @end
@@ -9,9 +9,9 @@
9
9
  #import "RCPaywallFooterViewManager.h"
10
10
 
11
11
  @import RevenueCatUI;
12
- @import PurchasesHybridCommon;
12
+ @import PurchasesHybridCommonUI;
13
13
 
14
- #import "UIView+Extensions.h"
14
+ #import "PaywallViewWrapper.h"
15
15
 
16
16
  #import <React/RCTShadowView.h>
17
17
  #import <React/RCTUIManager.h>
@@ -22,7 +22,7 @@
22
22
 
23
23
  NS_ASSUME_NONNULL_BEGIN
24
24
 
25
- @interface FooterViewWrapper : UIView
25
+ @interface FooterViewWrapper: PaywallViewWrapper
26
26
 
27
27
  - (instancetype)initWithFooterViewController:(UIViewController *)footerViewController
28
28
  bridge:(RCTBridge *)bridge;
@@ -33,7 +33,6 @@ NS_ASSUME_NONNULL_END
33
33
 
34
34
  @interface FooterViewWrapper () <RCPaywallViewControllerDelegate>
35
35
 
36
- @property (strong, nonatomic) UIViewController *footerViewController;
37
36
  @property (strong, nonatomic) RCTBridge *bridge;
38
37
 
39
38
  @property BOOL addedToHierarchy;
@@ -43,9 +42,8 @@ NS_ASSUME_NONNULL_END
43
42
  @implementation FooterViewWrapper
44
43
 
45
44
  - (instancetype)initWithFooterViewController:(UIViewController *)footerViewController bridge:(RCTBridge *)bridge {
46
- if ((self = [super initWithFrame:footerViewController.view.bounds])) {
45
+ if ((self = [super initWithPaywallViewController:footerViewController])) {
47
46
  _bridge = bridge;
48
- _footerViewController = footerViewController;
49
47
  }
50
48
 
51
49
  return self;
@@ -70,33 +68,7 @@ NS_ASSUME_NONNULL_END
70
68
  }
71
69
 
72
70
  - (void)paywallViewController:(RCPaywallViewController *)controller didChangeSizeTo:(CGSize)size API_AVAILABLE(ios(15.0)){
73
- [_bridge.uiManager setSize:size forView:self];
74
- }
75
-
76
- - (void)layoutSubviews {
77
- [super layoutSubviews];
78
-
79
- // Need to wait for this view to be in the hierarchy to look for the parent UIVC.
80
- // This is required to add a SwiftUI `UIHostingController` to the hierarchy in a way that allows
81
- // UIKit to read properties from the environment, like traits and safe area.
82
- if (!self.addedToHierarchy) {
83
- UIViewController *parentController = self.parentViewController;
84
- if (parentController) {
85
- self.footerViewController.view.translatesAutoresizingMaskIntoConstraints = NO;
86
- [parentController addChildViewController:self.footerViewController];
87
- [self addSubview:self.footerViewController.view];
88
- [self.footerViewController didMoveToParentViewController:parentController];
89
-
90
- [NSLayoutConstraint activateConstraints:@[
91
- [self.footerViewController.view.topAnchor constraintEqualToAnchor:self.topAnchor],
92
- [self.footerViewController.view.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
93
- [self.footerViewController.view.leftAnchor constraintEqualToAnchor:self.leftAnchor],
94
- [self.footerViewController.view.rightAnchor constraintEqualToAnchor:self.rightAnchor]
95
- ]];
96
-
97
- self.addedToHierarchy = YES;
98
- }
99
- }
71
+ [_bridge.uiManager setIntrinsicContentSize:CGSizeMake(UIViewNoIntrinsicMetric, size.height) forView:self];
100
72
  }
101
73
 
102
74
  @end
package/ios/RNPaywalls.h CHANGED
@@ -5,9 +5,6 @@
5
5
 
6
6
  #import <React/RCTEventEmitter.h>
7
7
 
8
- @import PurchasesHybridCommon;
9
- @import RevenueCat;
10
-
11
8
  static NSString *const safeAreaInsetsDidChangeEvent = @"safeAreaInsetsDidChange";
12
9
 
13
10
  @interface RNPaywalls : RCTEventEmitter <RCTBridgeModule>
package/ios/RNPaywalls.m CHANGED
@@ -6,6 +6,9 @@
6
6
 
7
7
  #import "RNPaywalls.h"
8
8
 
9
+ @import PurchasesHybridCommonUI;
10
+ @import RevenueCat;
11
+
9
12
  @interface RNPaywalls ()
10
13
 
11
14
  @property (nonatomic, strong) id paywallProxy;
@@ -58,21 +61,20 @@ RCT_EXPORT_MODULE();
58
61
 
59
62
  // MARK: -
60
63
 
61
- RCT_EXPORT_METHOD(presentPaywall:(NSDictionary *)options
64
+ RCT_EXPORT_METHOD(presentPaywall:(nullable NSString *)offeringIdentifier
65
+ shouldDisplayCloseButton:(BOOL)displayCloseButton
62
66
  withResolve:(RCTPromiseResolveBlock)resolve
63
67
  reject:(RCTPromiseRejectBlock)reject) {
64
68
  if (@available(iOS 15.0, *)) {
65
- // TODO wire offeringIdentifier
66
- NSString *offeringIdentifier = options[@"offeringIdentifier"];
67
- NSNumber *displayCloseButton = options[@"displayCloseButton"];
68
-
69
- if (displayCloseButton == nil) {
70
- [self.paywallProxy presentPaywallWithPaywallResultHandler:^(NSString *result) {
69
+ if (offeringIdentifier != nil) {
70
+ [self.paywalls presentPaywallWithOfferingIdentifier:offeringIdentifier
71
+ displayCloseButton:displayCloseButton
72
+ paywallResultHandler:^(NSString *result) {
71
73
  resolve(result);
72
74
  }];
73
75
  return;
74
76
  }
75
- [self.paywalls presentPaywallWithDisplayCloseButton:displayCloseButton.boolValue
77
+ [self.paywalls presentPaywallWithDisplayCloseButton:displayCloseButton
76
78
  paywallResultHandler:^(NSString *result) {
77
79
  resolve(result);
78
80
  }];
@@ -81,24 +83,23 @@ RCT_EXPORT_METHOD(presentPaywall:(NSDictionary *)options
81
83
  }
82
84
  }
83
85
 
84
- RCT_EXPORT_METHOD(presentPaywallIfNeeded:(NSDictionary *)options
86
+ RCT_EXPORT_METHOD(presentPaywallIfNeeded:(NSString *)requiredEntitlementIdentifier
87
+ withOfferingIdentifier:(nullable NSString *)offeringIdentifier
88
+ shouldDisplayCloseButton:(BOOL)displayCloseButton
85
89
  withResolve:(RCTPromiseResolveBlock)resolve
86
90
  reject:(RCTPromiseRejectBlock)reject) {
87
91
  if (@available(iOS 15.0, *)) {
88
- NSString *requiredEntitlementIdentifier = options[@"requiredEntitlementIdentifier"];
89
- // TODO wire offeringIdentifier
90
- NSString *offeringIdentifier = options[@"offeringIdentifier"];
91
- NSNumber *displayCloseButton = options[@"displayCloseButton"];
92
- if (displayCloseButton == nil) {
92
+ if (offeringIdentifier != nil) {
93
93
  [self.paywalls presentPaywallIfNeededWithRequiredEntitlementIdentifier:requiredEntitlementIdentifier
94
+ offeringIdentifier:offeringIdentifier
95
+ displayCloseButton:displayCloseButton
94
96
  paywallResultHandler:^(NSString *result) {
95
97
  resolve(result);
96
98
  }];
97
99
  return;
98
100
  }
99
-
100
101
  [self.paywalls presentPaywallIfNeededWithRequiredEntitlementIdentifier:requiredEntitlementIdentifier
101
- displayCloseButton:displayCloseButton.boolValue
102
+ displayCloseButton:displayCloseButton
102
103
  paywallResultHandler:^(NSString *result) {
103
104
  resolve(result);
104
105
  }];
@@ -10,6 +10,6 @@
10
10
 
11
11
  @interface UIView (ParentViewController)
12
12
 
13
- - (UIViewController *)parentViewController;
13
+ @property (nonatomic, readonly) UIViewController *_Nullable parentViewController;
14
14
 
15
15
  @end
@@ -9,7 +9,7 @@
9
9
 
10
10
  @implementation UIView (ParentViewController)
11
11
 
12
- - (UIViewController *)parentViewController {
12
+ - (UIViewController * _Nullable)parentViewController {
13
13
  UIResponder *responder = self;
14
14
  while (responder) {
15
15
  responder = responder.nextResponder;
@@ -29,17 +29,53 @@ const InternalPaywallFooterView = _reactNative.UIManager.getViewManagerConfig('P
29
29
  throw new Error(LINKING_ERROR);
30
30
  };
31
31
  class RevenueCatUI {
32
+ static Defaults = {
33
+ PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON: true
34
+ };
35
+
32
36
  /**
33
37
  * The result of presenting a paywall. This will be the last situation the user experienced before the paywall closed.
34
38
  * @readonly
35
39
  * @enum {string}
36
40
  */
37
41
  static PAYWALL_RESULT = _purchasesTypescriptInternal.PAYWALL_RESULT;
38
- static presentPaywall(params = {}) {
39
- return RNPaywalls.presentPaywall(params);
42
+
43
+ /**
44
+ * Presents a paywall to the user with optional customization.
45
+ *
46
+ * This method allows for presenting a specific offering's paywall to the user. The caller
47
+ * can decide whether to display a close button on the paywall through the `displayCloseButton`
48
+ * parameter. By default, the close button is displayed.
49
+ *
50
+ * @param {PresentPaywallParams} params - The options for presenting the paywall.
51
+ * @returns {Promise<PAYWALL_RESULT>} A promise that resolves with the result of the paywall presentation.
52
+ */
53
+ static presentPaywall({
54
+ offering,
55
+ displayCloseButton = RevenueCatUI.Defaults.PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON
56
+ } = {}) {
57
+ return RNPaywalls.presentPaywall((offering === null || offering === void 0 ? void 0 : offering.identifier) ?? null, displayCloseButton);
40
58
  }
41
- static presentPaywallIfNeeded(params) {
42
- return RNPaywalls.presentPaywallIfNeeded(params);
59
+
60
+ /**
61
+ * Presents a paywall to the user if a specific entitlement is not already owned.
62
+ *
63
+ * This method evaluates whether the user already owns the specified entitlement.
64
+ * If the entitlement is not owned, it presents a paywall for the specified offering (if provided), or the
65
+ * default offering (if no offering is provided), to the user. The paywall will be presented
66
+ * allowing the user the opportunity to purchase the offering. The caller
67
+ * can decide whether to display a close button on the paywall through the `displayCloseButton`
68
+ * parameter. By default, the close button is displayed.
69
+ *
70
+ * @param {PresentPaywallIfNeededParams} params - The parameters for presenting the paywall.
71
+ * @returns {Promise<PAYWALL_RESULT>} A promise that resolves with the result of the paywall presentation.
72
+ */
73
+ static presentPaywallIfNeeded({
74
+ requiredEntitlementIdentifier,
75
+ offering,
76
+ displayCloseButton = RevenueCatUI.Defaults.PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON
77
+ }) {
78
+ return RNPaywalls.presentPaywallIfNeeded(requiredEntitlementIdentifier, (offering === null || offering === void 0 ? void 0 : offering.identifier) ?? null, displayCloseButton);
43
79
  }
44
80
  static Paywall = props => /*#__PURE__*/_react.default.createElement(InternalPaywall, _extends({}, props, {
45
81
  style: [{
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_purchasesTypescriptInternal","_react","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","LINKING_ERROR","Platform","select","ios","RNPaywalls","NativeModules","eventEmitter","NativeEventEmitter","InternalPaywall","UIManager","getViewManagerConfig","requireNativeComponent","Error","InternalPaywallFooterView","RevenueCatUI","PAYWALL_RESULT","presentPaywall","params","presentPaywallIfNeeded","Paywall","props","createElement","style","flex","PaywallFooterContainerView","children","paddingBottom","setPaddingBottom","useState","useEffect","handleSafeAreaInsetsChange","bottom","subscription","addListener","remove","View","ScrollView","contentContainerStyle","flexGrow","marginTop","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAAC,4BAAA,GAAAD,OAAA;AACA,IAA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C;EAEX,CAAC;AACH;AAACC,OAAA,CAAAhE,OAAA,GAAAsC,YAAA"}
1
+ {"version":3,"names":["_reactNative","require","_purchasesTypescriptInternal","_react","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","LINKING_ERROR","Platform","select","ios","RNPaywalls","NativeModules","eventEmitter","NativeEventEmitter","InternalPaywall","UIManager","getViewManagerConfig","requireNativeComponent","Error","InternalPaywallFooterView","RevenueCatUI","Defaults","PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON","PAYWALL_RESULT","presentPaywall","offering","displayCloseButton","identifier","presentPaywallIfNeeded","requiredEntitlementIdentifier","Paywall","props","createElement","style","flex","PaywallFooterContainerView","children","paddingBottom","setPaddingBottom","useState","useEffect","handleSafeAreaInsetsChange","bottom","subscription","addListener","remove","View","ScrollView","contentContainerStyle","flexGrow","marginTop","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAAC,4BAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAmE,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CA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AC;MAAE;IAAE,CAAC,CAChD,CAAC;EAEX,CAAC;AACH;AAACC,OAAA,CAAArE,OAAA,GAAAsC,YAAA"}
@@ -16,17 +16,53 @@ const InternalPaywallFooterView = UIManager.getViewManagerConfig('Paywall') != n
16
16
  throw new Error(LINKING_ERROR);
17
17
  };
18
18
  export default class RevenueCatUI {
19
+ static Defaults = {
20
+ PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON: true
21
+ };
22
+
19
23
  /**
20
24
  * The result of presenting a paywall. This will be the last situation the user experienced before the paywall closed.
21
25
  * @readonly
22
26
  * @enum {string}
23
27
  */
24
28
  static PAYWALL_RESULT = PAYWALL_RESULT;
25
- static presentPaywall(params = {}) {
26
- return RNPaywalls.presentPaywall(params);
29
+
30
+ /**
31
+ * Presents a paywall to the user with optional customization.
32
+ *
33
+ * This method allows for presenting a specific offering's paywall to the user. The caller
34
+ * can decide whether to display a close button on the paywall through the `displayCloseButton`
35
+ * parameter. By default, the close button is displayed.
36
+ *
37
+ * @param {PresentPaywallParams} params - The options for presenting the paywall.
38
+ * @returns {Promise<PAYWALL_RESULT>} A promise that resolves with the result of the paywall presentation.
39
+ */
40
+ static presentPaywall({
41
+ offering,
42
+ displayCloseButton = RevenueCatUI.Defaults.PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON
43
+ } = {}) {
44
+ return RNPaywalls.presentPaywall((offering === null || offering === void 0 ? void 0 : offering.identifier) ?? null, displayCloseButton);
27
45
  }
28
- static presentPaywallIfNeeded(params) {
29
- return RNPaywalls.presentPaywallIfNeeded(params);
46
+
47
+ /**
48
+ * Presents a paywall to the user if a specific entitlement is not already owned.
49
+ *
50
+ * This method evaluates whether the user already owns the specified entitlement.
51
+ * If the entitlement is not owned, it presents a paywall for the specified offering (if provided), or the
52
+ * default offering (if no offering is provided), to the user. The paywall will be presented
53
+ * allowing the user the opportunity to purchase the offering. The caller
54
+ * can decide whether to display a close button on the paywall through the `displayCloseButton`
55
+ * parameter. By default, the close button is displayed.
56
+ *
57
+ * @param {PresentPaywallIfNeededParams} params - The parameters for presenting the paywall.
58
+ * @returns {Promise<PAYWALL_RESULT>} A promise that resolves with the result of the paywall presentation.
59
+ */
60
+ static presentPaywallIfNeeded({
61
+ requiredEntitlementIdentifier,
62
+ offering,
63
+ displayCloseButton = RevenueCatUI.Defaults.PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON
64
+ }) {
65
+ return RNPaywalls.presentPaywallIfNeeded(requiredEntitlementIdentifier, (offering === null || offering === void 0 ? void 0 : offering.identifier) ?? null, displayCloseButton);
30
66
  }
31
67
  static Paywall = props => /*#__PURE__*/React.createElement(InternalPaywall, _extends({}, props, {
32
68
  style: [{
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","Platform","requireNativeComponent","ScrollView","UIManager","View","PAYWALL_RESULT","React","useEffect","useState","LINKING_ERROR","select","ios","default","RNPaywalls","eventEmitter","InternalPaywall","getViewManagerConfig","Error","InternalPaywallFooterView","RevenueCatUI","presentPaywall","params","presentPaywallIfNeeded","Paywall","props","createElement","_extends","style","flex","PaywallFooterContainerView","children","paddingBottom","setPaddingBottom","handleSafeAreaInsetsChange","bottom","subscription","addListener","remove","contentContainerStyle","flexGrow","marginTop"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";AAAA,SACEA,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,EACRC,sBAAsB,EACtBC,UAAU,EAEVC,SAAS,EACTC,IAAI,QAEC,cAAc;AACrB,SAASC,cAAc,QAAQ,2CAA2C;AAC1E,OAAOC,KAAK,IAAoBC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAElE,SAASH,cAAc,QAAQ,2CAA2C;AAE1E,MAAMI,aAAa,GAChB,sFAAqF,GACtFT,QAAQ,CAACU,MAAM,CAAC;EAACC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAE,CAAC,CAAC,GACrE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,UAAU,GAAG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BAAgB,CAAC,EAAE,GAAGE,MAAM,CAAC;MAC/B,CAAC;MAED,MAAMC,YAAY,GAAGrB,YAAY,CAACsB,WAAW,CAC3C,yBAAyB,EACzBH,0BACF,CAAC;MAED,OAAO,MAAM;QACXE,YAAY,CAACE,MAAM,CAAC,CAAC;MACvB,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;IAEN,oBACE/B,KAAA,CAAAmB,aAAA,CAACrB,IAAI;MAACuB,KAAK,EAAE,CAAC;QAACC,IAAI,EAAE;MAAC,CAAC,EAAED,KAAK;IAAE,gBAC9BrB,KAAA,CAAAmB,aAAA,CAACvB,UAAU;MAACoC,qBAAqB,EAAE;QAACC,QAAQ,EAAE,CAAC;QAAER;MAAa;IAAE,GAC7DD,QACS,CAAC,eAEbxB,KAAA,CAAAmB,aAAA,CAACP,yBAAyB;MAACS,KAAK,EAAE;QAACa,SAAS,EAAE,CAAC;MAAE;IAAE,CAAC,CAChD,CAAC;EAEX,CAAC;AACH"}
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","Platform","requireNativeComponent","ScrollView","UIManager","View","PAYWALL_RESULT","React","useEffect","useState","LINKING_ERROR","select","ios","default","RNPaywalls","eventEmitter","InternalPaywall","getViewManagerConfig","Error","InternalPaywallFooterView","RevenueCatUI","Defaults","PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON","presentPaywall","offering","displayCloseButton","identifier","presentPaywallIfNeeded","requiredEntitlementIdentifier","Paywall","props","createElement","_extends","style","flex","PaywallFooterContainerView","children","paddingBottom","setPaddingBottom","handleSafeAreaInsetsChange","bottom","subscription","addListener","remove","contentContainerStyle","flexGrow","marginTop"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";AAAA,SACEA,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,EACRC,sBAAsB,EACtBC,UAAU,EAEVC,SAAS,EACTC,IAAI,QAEC,cAAc;AACrB,SAASC,cAAc,QAAgC,2CAA2C;AAClG,OAAOC,KAAK,IAAoBC,SAA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AA,CAAAwB,aAAA,CAACZ,yBAAyB;MAACc,KAAK,EAAE;QAACa,SAAS,EAAE,CAAC;MAAE;IAAE,CAAC,CAChD,CAAC;EAEX,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
1
  import { type StyleProp, type ViewStyle } from "react-native";
2
- import { PAYWALL_RESULT } from "@revenuecat/purchases-typescript-internal";
2
+ import { PAYWALL_RESULT, type PurchasesOffering } from "@revenuecat/purchases-typescript-internal";
3
3
  import React, { type ReactNode } from "react";
4
4
  export { PAYWALL_RESULT } from "@revenuecat/purchases-typescript-internal";
5
5
  type PaywallViewProps = {
@@ -11,6 +11,10 @@ export interface PresentPaywallParams {
11
11
  * Whether to display the close button or not.
12
12
  */
13
13
  displayCloseButton?: boolean;
14
+ /**
15
+ * The offering to load the paywall with. This will be the "current" offering by default.
16
+ */
17
+ offering?: PurchasesOffering;
14
18
  }
15
19
  export type PresentPaywallIfNeededParams = PresentPaywallParams & {
16
20
  /**
@@ -19,14 +23,38 @@ export type PresentPaywallIfNeededParams = PresentPaywallParams & {
19
23
  requiredEntitlementIdentifier: string;
20
24
  };
21
25
  export default class RevenueCatUI {
26
+ private static Defaults;
22
27
  /**
23
28
  * The result of presenting a paywall. This will be the last situation the user experienced before the paywall closed.
24
29
  * @readonly
25
30
  * @enum {string}
26
31
  */
27
32
  static PAYWALL_RESULT: typeof PAYWALL_RESULT;
28
- static presentPaywall(params?: PresentPaywallParams): Promise<PAYWALL_RESULT>;
29
- static presentPaywallIfNeeded(params: PresentPaywallIfNeededParams): Promise<PAYWALL_RESULT>;
33
+ /**
34
+ * Presents a paywall to the user with optional customization.
35
+ *
36
+ * This method allows for presenting a specific offering's paywall to the user. The caller
37
+ * can decide whether to display a close button on the paywall through the `displayCloseButton`
38
+ * parameter. By default, the close button is displayed.
39
+ *
40
+ * @param {PresentPaywallParams} params - The options for presenting the paywall.
41
+ * @returns {Promise<PAYWALL_RESULT>} A promise that resolves with the result of the paywall presentation.
42
+ */
43
+ static presentPaywall({ offering, displayCloseButton }?: PresentPaywallParams): Promise<PAYWALL_RESULT>;
44
+ /**
45
+ * Presents a paywall to the user if a specific entitlement is not already owned.
46
+ *
47
+ * This method evaluates whether the user already owns the specified entitlement.
48
+ * If the entitlement is not owned, it presents a paywall for the specified offering (if provided), or the
49
+ * default offering (if no offering is provided), to the user. The paywall will be presented
50
+ * allowing the user the opportunity to purchase the offering. The caller
51
+ * can decide whether to display a close button on the paywall through the `displayCloseButton`
52
+ * parameter. By default, the close button is displayed.
53
+ *
54
+ * @param {PresentPaywallIfNeededParams} params - The parameters for presenting the paywall.
55
+ * @returns {Promise<PAYWALL_RESULT>} A promise that resolves with the result of the paywall presentation.
56
+ */
57
+ static presentPaywallIfNeeded({ requiredEntitlementIdentifier, offering, displayCloseButton }: PresentPaywallIfNeededParams): Promise<PAYWALL_RESULT>;
30
58
  static Paywall: React.FC<PaywallViewProps>;
31
59
  static PaywallFooterContainerView: React.FC<PaywallViewProps>;
32
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EAGd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAY3E,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAeF,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,GAAG;IAChE;;OAEG;IACH,6BAA6B,EAAE,MAAM,CA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AAc,CAAC,EACE,QAAQ,EACR,kBAA+E,EAChF,GAAE,oBAAyB,GAAG,OAAO,CAAC,cAAc,CAAC;IAInF;;;;;;;;;;;;OAYG;WACW,sBAAsB,CAAC,EACE,6BAA6B,EAC7B,QAAQ,EACR,kBAA+E,EAChF,EAAE,4BAA4B,GAAG,OAAO,CAAC,cAAc,CAAC;IAI9F,OAAc,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAE/C;IAEF,OAAc,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAmClE;CACH"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-purchases-ui",
3
3
  "title": "React Native Purchases UI",
4
- "version": "7.16.1",
4
+ "version": "7.17.1",
5
5
  "description": "React Native in-app purchases and subscriptions made easy. Supports iOS and Android.",
6
6
  "main": "lib/commonjs/index",
7
7
  "module": "lib/module/index",
@@ -112,6 +112,6 @@
112
112
  },
113
113
  "dependencies": {
114
114
  "@revenuecat/purchases-typescript-internal": "8.10.1",
115
- "react-native-purchases": "7.16.1"
115
+ "react-native-purchases": "7.17.1"
116
116
  }
117
117
  }
package/src/index.tsx CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  View,
10
10
  type ViewStyle,
11
11
  } from "react-native";
12
- import { PAYWALL_RESULT } from "@revenuecat/purchases-typescript-internal";
12
+ import { PAYWALL_RESULT, type PurchasesOffering } from "@revenuecat/purchases-typescript-internal";
13
13
  import React, { type ReactNode, useEffect, useState } from "react";
14
14
 
15
15
  export { PAYWALL_RESULT } from "@revenuecat/purchases-typescript-internal";
@@ -47,6 +47,11 @@ export interface PresentPaywallParams {
47
47
  * Whether to display the close button or not.
48
48
  */
49
49
  displayCloseButton?: boolean;
50
+
51
+ /**
52
+ * The offering to load the paywall with. This will be the "current" offering by default.
53
+ */
54
+ offering?: PurchasesOffering;
50
55
  }
51
56
 
52
57
  export type PresentPaywallIfNeededParams = PresentPaywallParams & {
@@ -58,6 +63,10 @@ export type PresentPaywallIfNeededParams = PresentPaywallParams & {
58
63
 
59
64
  export default class RevenueCatUI {
60
65
 
66
+ private static Defaults = {
67
+ PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON: true
68
+ }
69
+
61
70
  /**
62
71
  * The result of presenting a paywall. This will be the last situation the user experienced before the paywall closed.
63
72
  * @readonly
@@ -65,12 +74,42 @@ export default class RevenueCatUI {
65
74
  */
66
75
  public static PAYWALL_RESULT = PAYWALL_RESULT;
67
76
 
68
- public static presentPaywall(params: PresentPaywallParams = {}): Promise<PAYWALL_RESULT> {
69
- return RNPaywalls.presentPaywall(params);
77
+ /**
78
+ * Presents a paywall to the user with optional customization.
79
+ *
80
+ * This method allows for presenting a specific offering's paywall to the user. The caller
81
+ * can decide whether to display a close button on the paywall through the `displayCloseButton`
82
+ * parameter. By default, the close button is displayed.
83
+ *
84
+ * @param {PresentPaywallParams} params - The options for presenting the paywall.
85
+ * @returns {Promise<PAYWALL_RESULT>} A promise that resolves with the result of the paywall presentation.
86
+ */
87
+ public static presentPaywall({
88
+ offering,
89
+ displayCloseButton = RevenueCatUI.Defaults.PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON
90
+ }: PresentPaywallParams = {}): Promise<PAYWALL_RESULT> {
91
+ return RNPaywalls.presentPaywall(offering?.identifier ?? null, displayCloseButton)
70
92
  }
71
93
 
72
- public static presentPaywallIfNeeded(params: PresentPaywallIfNeededParams): Promise<PAYWALL_RESULT> {
73
- return RNPaywalls.presentPaywallIfNeeded(params);
94
+ /**
95
+ * Presents a paywall to the user if a specific entitlement is not already owned.
96
+ *
97
+ * This method evaluates whether the user already owns the specified entitlement.
98
+ * If the entitlement is not owned, it presents a paywall for the specified offering (if provided), or the
99
+ * default offering (if no offering is provided), to the user. The paywall will be presented
100
+ * allowing the user the opportunity to purchase the offering. The caller
101
+ * can decide whether to display a close button on the paywall through the `displayCloseButton`
102
+ * parameter. By default, the close button is displayed.
103
+ *
104
+ * @param {PresentPaywallIfNeededParams} params - The parameters for presenting the paywall.
105
+ * @returns {Promise<PAYWALL_RESULT>} A promise that resolves with the result of the paywall presentation.
106
+ */
107
+ public static presentPaywallIfNeeded({
108
+ requiredEntitlementIdentifier,
109
+ offering,
110
+ displayCloseButton = RevenueCatUI.Defaults.PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON
111
+ }: PresentPaywallIfNeededParams): Promise<PAYWALL_RESULT> {
112
+ return RNPaywalls.presentPaywallIfNeeded(requiredEntitlementIdentifier, offering?.identifier ?? null, displayCloseButton)
74
113
  }
75
114
 
76
115
  public static Paywall: React.FC<PaywallViewProps> = (props) => (