react-native-purchases-ui 8.11.5 → 8.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![License](https://img.shields.io/cocoapods/l/RevenueCat.svg?style=flat)](http://cocoapods.org/pods/RevenueCat)
4
4
 
5
- RevenueCat is a powerful, reliable, and free to use in-app purchase server with cross-platform support. Our open-source framework provides a backend and a wrapper around StoreKit and Google Play Billing to make implementing in-app purchases and subscriptions easy.
5
+ RevenueCat is a powerful, reliable, and free-to-use in-app purchase server with cross-platform support. Our open-source framework provides a backend and a wrapper around StoreKit and Google Play Billing to make implementing in-app purchases and subscriptions easy.
6
6
 
7
7
  Whether you are building a new app or already have millions of customers, you can use RevenueCat to:
8
8
 
@@ -15,6 +15,133 @@ Whether you are building a new app or already have millions of customers, you ca
15
15
 
16
16
  Sign up to [get started for free](https://app.revenuecat.com/signup).
17
17
 
18
+ ---
19
+
18
20
  ## React Native Purchases UI
19
21
 
20
- React Native Purchases UI is the client for the [RevenueCat](https://www.revenuecat.com/) subscription and purchase tracking system. It is an open source framework that provides a wrapper around `StoreKit`, `Google Play Billing` and the RevenueCat backend to make implementing in-app purchases in `React Native` easy.
22
+ React Native Purchases UI are the UI components for the [RevenueCat](https://www.revenuecat.com/) subscription and purchase tracking system. It allows you to present paywalls in your React Native application, which you can further customize through the RevenueCat dashboard.
23
+
24
+ ## Installation
25
+
26
+ Expo supports in-app payments and is compatible with `react-native-purchases-ui`. You can install this package in an non-development build using the Expo Go app. In this case, `react-native-purchases-ui` will run in a Preview API mode, as it requires some native modules that are not available in Expo Go. All the listed APIs below are available but have no effect.
27
+
28
+ [Creating a development build](https://docs.expo.dev/get-started/set-up-your-environment/?mode=development-build) of the app will allow you to test the real behavior of RevenueCat SDK.
29
+
30
+
31
+ ---
32
+
33
+ ### 📱 Paywall Presentation Options
34
+
35
+ RevenueCat provides multiple ways to display paywalls in your app, depending on your use case:
36
+
37
+ #### 1. `RevenueCatUI.presentPaywall()`
38
+
39
+ Presents the current offering’s paywall modally.
40
+
41
+ ```tsx
42
+ import RevenueCatUI, { PAYWALL_RESULT } from "react-native-purchases-ui";
43
+
44
+ async function presentPaywall(): Promise<boolean> {
45
+ const paywallResult: PAYWALL_RESULT = await RevenueCatUI.presentPaywall();
46
+
47
+ switch (paywallResult) {
48
+ case PAYWALL_RESULT.NOT_PRESENTED:
49
+ case PAYWALL_RESULT.ERROR:
50
+ case PAYWALL_RESULT.CANCELLED:
51
+ return false;
52
+ case PAYWALL_RESULT.PURCHASED:
53
+ case PAYWALL_RESULT.RESTORED:
54
+ return true;
55
+ default:
56
+ return false;
57
+ }
58
+ }
59
+ ```
60
+
61
+
62
+ Optionally, pass an offering object to display a specific offering:
63
+
64
+ ```tsx
65
+ await RevenueCatUI.presentPaywall({ offering });
66
+ ```
67
+
68
+ #### 2. RevenueCatUI.presentPaywallIfNeeded()
69
+
70
+ Displays the paywall **only if the required entitlement is not unlocked** (useful for gating access).
71
+
72
+ ```tsx
73
+ const result = await RevenueCatUI.presentPaywallIfNeeded({
74
+ requiredEntitlementIdentifier: "pro"
75
+ });
76
+ ```
77
+
78
+ With a specific offering:
79
+
80
+ ```tsx
81
+ await RevenueCatUI.presentPaywallIfNeeded({
82
+ offering,
83
+ requiredEntitlementIdentifier: "pro"
84
+ });
85
+ ```
86
+
87
+ #### 3. <RevenueCatUI.Paywall /> Component
88
+
89
+ This approach provides manual control over when and how the paywall is rendered in your component tree.
90
+
91
+ **Displaying the Current Offering**
92
+
93
+ ```tsx
94
+ import React from 'react';
95
+ import { View } from 'react-native';
96
+ import RevenueCatUI from 'react-native-purchases-ui';
97
+
98
+ return (
99
+ <View style={{ flex: 1 }}>
100
+ <RevenueCatUI.Paywall
101
+ onDismiss={() => {
102
+ // Dismiss the paywall, i.e. remove the view, navigate to another screen, etc.
103
+ // Will be called when the close button is pressed (if enabled) or when a purchase succeeds.
104
+ }}
105
+ />
106
+ </View>
107
+ );
108
+ ```
109
+
110
+ **Displaying a Specific Offering**
111
+
112
+ ```tsx
113
+ import React from 'react';
114
+ import { View } from 'react-native';
115
+ import RevenueCatUI from 'react-native-purchases-ui';
116
+
117
+ return (
118
+ <View style={{ flex: 1 }}>
119
+ <RevenueCatUI.Paywall
120
+ options={{
121
+ offering: offering // Optional Offering object obtained through getOfferings
122
+ }}
123
+ onRestoreCompleted={({ customerInfo }: { customerInfo: CustomerInfo }) => {
124
+ // Optional listener. Called when a restore has been completed.
125
+ // This may be called even if no entitlements have been granted.
126
+ }}
127
+ onDismiss={() => {
128
+ // Dismiss the paywall, i.e. remove the view, navigate to another screen, etc.
129
+ // Will be called when the close button is pressed (if enabled) or when a purchase succeeds.
130
+ }}
131
+ />
132
+ </View>
133
+ );
134
+ ```
135
+
136
+ Listeners
137
+ The `<Paywall />` component supports the following lifecycle listeners:
138
+ - onPurchaseStarted
139
+ - onPurchaseCompleted
140
+ - onPurchaseError
141
+ - onPurchaseCancelled
142
+ - onRestoreStarted
143
+ - onRestoreCompleted
144
+ - onRestoreError
145
+ - onDismiss
146
+
147
+ Use these callbacks to respond to user actions such as purchase initiation, completion, dismissal, and error handling.
@@ -59,7 +59,7 @@ android {
59
59
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
60
60
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
61
61
  versionCode 1
62
- versionName '8.11.5'
62
+ versionName '8.11.6'
63
63
  }
64
64
 
65
65
  buildTypes {
@@ -89,21 +89,25 @@ internal class RNPaywallsModule(
89
89
  val fontFamily = fontFamilyName?.let {
90
90
  FontAssetManager.getPaywallFontFamily(fontFamilyName = it, activity.resources.assets)
91
91
  }
92
- presentPaywallFromFragment(
93
- activity = activity,
94
- PresentPaywallOptions(
95
- requiredEntitlementIdentifier = requiredEntitlementIdentifier,
96
- shouldDisplayDismissButton = displayCloseButton,
97
- paywallSource = offeringIdentifier?.let {
98
- PaywallSource.OfferingIdentifier(it)
99
- } ?: PaywallSource.DefaultOffering,
100
- paywallResultListener = object : PaywallResultListener {
101
- override fun onPaywallResult(paywallResult: String) {
102
- promise.resolve(paywallResult)
103
- }
104
- },
105
- fontFamily = fontFamily
92
+
93
+ // @ReactMethod is not guaranteed to run on the main thread
94
+ activity.runOnUiThread {
95
+ presentPaywallFromFragment(
96
+ activity = activity,
97
+ PresentPaywallOptions(
98
+ requiredEntitlementIdentifier = requiredEntitlementIdentifier,
99
+ shouldDisplayDismissButton = displayCloseButton,
100
+ paywallSource = offeringIdentifier?.let {
101
+ PaywallSource.OfferingIdentifier(it)
102
+ } ?: PaywallSource.DefaultOffering,
103
+ paywallResultListener = object : PaywallResultListener {
104
+ override fun onPaywallResult(paywallResult: String) {
105
+ promise.resolve(paywallResult)
106
+ }
107
+ },
108
+ fontFamily = fontFamily
109
+ )
106
110
  )
107
- )
111
+ }
108
112
  }
109
113
  }
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": "8.11.5",
4
+ "version": "8.11.6",
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",
@@ -115,6 +115,6 @@
115
115
  },
116
116
  "dependencies": {
117
117
  "@revenuecat/purchases-typescript-internal": "13.37.0",
118
- "react-native-purchases": "8.11.5"
118
+ "react-native-purchases": "8.11.6"
119
119
  }
120
120
  }