react-native-purchases-ui 7.20.0 → 7.21.0
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/android/build.gradle +1 -1
- package/android/src/main/java/com/revenuecat/purchases/react/ui/BasePaywallViewManager.kt +114 -0
- package/android/src/main/java/com/revenuecat/purchases/react/ui/PaywallEvent.kt +16 -0
- package/android/src/main/java/com/revenuecat/purchases/react/ui/PaywallFooterViewManager.kt +6 -8
- package/android/src/main/java/com/revenuecat/purchases/react/ui/PaywallViewManager.kt +5 -4
- package/android/src/main/java/com/revenuecat/purchases/react/ui/RNPurchasesConverters.kt +48 -0
- package/ios/PaywallViewManager.m +35 -2
- package/ios/PaywallViewWrapper.h +10 -1
- package/ios/PaywallViewWrapper.m +51 -7
- package/ios/RCPaywallFooterViewManager.m +12 -7
- package/lib/commonjs/index.js +35 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +35 -6
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +31 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +65 -5
package/android/build.gradle
CHANGED
|
@@ -2,13 +2,29 @@ package com.revenuecat.purchases.react.ui
|
|
|
2
2
|
|
|
3
3
|
import android.view.View
|
|
4
4
|
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
6
|
+
import com.facebook.react.common.MapBuilder
|
|
5
7
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
8
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
9
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
10
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
11
|
+
import com.revenuecat.purchases.hybridcommon.ui.PaywallListenerWrapper
|
|
7
12
|
|
|
8
13
|
internal abstract class BasePaywallViewManager<T : View> : SimpleViewManager<T>() {
|
|
9
14
|
|
|
10
15
|
abstract fun setOfferingId(view: T, identifier: String)
|
|
11
16
|
|
|
17
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any>? {
|
|
18
|
+
return MapBuilder.builder<String, Any>()
|
|
19
|
+
.putEvent(PaywallEvent.ON_PURCHASE_COMPLETED)
|
|
20
|
+
.putEvent(PaywallEvent.ON_PURCHASE_ERROR)
|
|
21
|
+
.putEvent(PaywallEvent.ON_PURCHASE_CANCELLED)
|
|
22
|
+
.putEvent(PaywallEvent.ON_RESTORE_COMPLETED)
|
|
23
|
+
.putEvent(PaywallEvent.ON_RESTORE_ERROR)
|
|
24
|
+
.putEvent(PaywallEvent.ON_DISMISS)
|
|
25
|
+
.build()
|
|
26
|
+
}
|
|
27
|
+
|
|
12
28
|
@ReactProp(name = "options")
|
|
13
29
|
fun setOptions(view: T, options: ReadableMap?) {
|
|
14
30
|
options?.let { props ->
|
|
@@ -21,5 +37,103 @@ internal abstract class BasePaywallViewManager<T : View> : SimpleViewManager<T>(
|
|
|
21
37
|
}
|
|
22
38
|
}
|
|
23
39
|
}
|
|
40
|
+
|
|
41
|
+
// TODO: RCTEventEmitter is deprecated, and RCTModernEventEmitter should be used instead
|
|
42
|
+
// but documentation is not clear on how to use it so keeping this for now
|
|
43
|
+
internal fun createPaywallListenerWrapper(
|
|
44
|
+
themedReactContext: ThemedReactContext,
|
|
45
|
+
view: View
|
|
46
|
+
) = object : PaywallListenerWrapper() {
|
|
47
|
+
|
|
48
|
+
override fun onPurchaseStarted(rcPackage: Map<String, Any?>) {
|
|
49
|
+
// Will implement when iOS sends package as argument
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override fun onPurchaseCompleted(
|
|
53
|
+
customerInfo: Map<String, Any?>,
|
|
54
|
+
storeTransaction: Map<String, Any?>
|
|
55
|
+
) {
|
|
56
|
+
val payload = mapOf(
|
|
57
|
+
PaywallEventKey.CUSTOMER_INFO to customerInfo,
|
|
58
|
+
PaywallEventKey.STORE_TRANSACTION to storeTransaction
|
|
59
|
+
)
|
|
60
|
+
emitEvent(themedReactContext, view.id, PaywallEvent.ON_PURCHASE_COMPLETED, payload)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
override fun onPurchaseError(error: Map<String, Any?>) {
|
|
64
|
+
val payload = mapOf(PaywallEventKey.ERROR to error)
|
|
65
|
+
emitEvent(themedReactContext, view.id, PaywallEvent.ON_PURCHASE_ERROR, payload)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
override fun onPurchaseCancelled() {
|
|
69
|
+
emitEvent(themedReactContext, view.id, PaywallEvent.ON_PURCHASE_CANCELLED)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
override fun onRestoreStarted() {
|
|
73
|
+
// Will implement when iOS starts sending this event
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override fun onRestoreCompleted(customerInfo: Map<String, Any?>) {
|
|
77
|
+
val payload = mapOf(PaywallEventKey.CUSTOMER_INFO to customerInfo)
|
|
78
|
+
emitEvent(themedReactContext, view.id, PaywallEvent.ON_RESTORE_COMPLETED, payload)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
override fun onRestoreError(error: Map<String, Any?>) {
|
|
82
|
+
val payload = mapOf(PaywallEventKey.ERROR to error)
|
|
83
|
+
emitEvent(themedReactContext, view.id, PaywallEvent.ON_RESTORE_ERROR, payload)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
internal fun getDismissHandler(
|
|
89
|
+
themedReactContext: ThemedReactContext,
|
|
90
|
+
view: T
|
|
91
|
+
): (() -> Unit) {
|
|
92
|
+
return {
|
|
93
|
+
emitEvent(themedReactContext, view.id, PaywallEvent.ON_DISMISS)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private fun MapBuilder.Builder<String, Any>.putEvent(
|
|
98
|
+
paywallEvent: PaywallEvent
|
|
99
|
+
): MapBuilder.Builder<String, Any> {
|
|
100
|
+
val registrationName = MapBuilder.of("registrationName", paywallEvent.eventName)
|
|
101
|
+
return this.put(paywallEvent.eventName, registrationName)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private fun WritableNativeMap.putMap(keyMap: PaywallEventKey, dictionary: Map<String, Any?>) {
|
|
105
|
+
putMap(
|
|
106
|
+
keyMap.key,
|
|
107
|
+
RNPurchasesConverters.convertMapToWriteableMap(dictionary)
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private fun emitEvent(
|
|
112
|
+
context: ThemedReactContext,
|
|
113
|
+
viewId: Int,
|
|
114
|
+
event: PaywallEvent,
|
|
115
|
+
payload: Map<PaywallEventKey, Map<String, Any?>>,
|
|
116
|
+
) {
|
|
117
|
+
val convertedPayload = WritableNativeMap().apply {
|
|
118
|
+
payload.forEach { (key, value) ->
|
|
119
|
+
putMap(key.key, RNPurchasesConverters.convertMapToWriteableMap(value))
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
emitEvent(context, viewId, event, convertedPayload)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@Suppress("DEPRECATION")
|
|
126
|
+
private fun emitEvent(
|
|
127
|
+
context: ThemedReactContext,
|
|
128
|
+
viewId: Int,
|
|
129
|
+
event: PaywallEvent,
|
|
130
|
+
payload: WritableNativeMap? = null
|
|
131
|
+
) {
|
|
132
|
+
context.getJSModule(RCTEventEmitter::class.java).receiveEvent(
|
|
133
|
+
viewId,
|
|
134
|
+
event.eventName,
|
|
135
|
+
payload
|
|
136
|
+
)
|
|
137
|
+
}
|
|
24
138
|
}
|
|
25
139
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.revenuecat.purchases.react.ui
|
|
2
|
+
|
|
3
|
+
internal enum class PaywallEvent(val eventName: String) {
|
|
4
|
+
ON_PURCHASE_COMPLETED("onPurchaseCompleted"),
|
|
5
|
+
ON_PURCHASE_ERROR("onPurchaseError"),
|
|
6
|
+
ON_PURCHASE_CANCELLED("onPurchaseCancelled"),
|
|
7
|
+
ON_RESTORE_COMPLETED("onRestoreCompleted"),
|
|
8
|
+
ON_RESTORE_ERROR("onRestoreError"),
|
|
9
|
+
ON_DISMISS("onDismiss");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
internal enum class PaywallEventKey(val key: String) {
|
|
13
|
+
CUSTOMER_INFO("customerInfo"),
|
|
14
|
+
STORE_TRANSACTION("storeTransaction"),
|
|
15
|
+
ERROR("error")
|
|
16
|
+
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
package com.revenuecat.purchases.react.ui
|
|
2
2
|
|
|
3
|
-
import android.annotation.SuppressLint
|
|
4
3
|
import androidx.core.view.children
|
|
5
|
-
import com.facebook.react.bridge.ReadableMap
|
|
6
|
-
import com.facebook.react.uimanager.SimpleViewManager
|
|
7
4
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
5
|
import com.facebook.react.uimanager.UIManagerModule
|
|
9
|
-
import com.facebook.react.uimanager.
|
|
6
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
10
7
|
import com.revenuecat.purchases.ui.revenuecatui.ExperimentalPreviewRevenueCatUIPurchasesAPI
|
|
11
8
|
import com.revenuecat.purchases.ui.revenuecatui.views.PaywallFooterView
|
|
12
9
|
|
|
10
|
+
|
|
13
11
|
@OptIn(ExperimentalPreviewRevenueCatUIPurchasesAPI::class)
|
|
14
12
|
internal class PaywallFooterViewManager : BasePaywallViewManager<PaywallFooterView>() {
|
|
15
13
|
|
|
@@ -17,9 +15,8 @@ internal class PaywallFooterViewManager : BasePaywallViewManager<PaywallFooterVi
|
|
|
17
15
|
return "RCPaywallFooterView"
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
@SuppressLint("UnsafeOptInUsageError")
|
|
21
18
|
override fun createViewInstance(themedReactContext: ThemedReactContext): PaywallFooterView {
|
|
22
|
-
|
|
19
|
+
return object : PaywallFooterView(themedReactContext) {
|
|
23
20
|
|
|
24
21
|
// This is required so the change from Loading to Loaded resizes the view
|
|
25
22
|
// https://github.com/facebook/react-native/issues/17968#issuecomment-1672111483
|
|
@@ -59,9 +56,10 @@ internal class PaywallFooterViewManager : BasePaywallViewManager<PaywallFooterVi
|
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
58
|
}
|
|
59
|
+
}.also {
|
|
60
|
+
it.setPaywallListener(createPaywallListenerWrapper(themedReactContext, it))
|
|
61
|
+
it.setDismissHandler(getDismissHandler(themedReactContext, it))
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
return paywallFooterView
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
override fun setOfferingId(view: PaywallFooterView, identifier: String) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
package com.revenuecat.purchases.react.ui
|
|
2
2
|
|
|
3
|
-
import com.facebook.react.bridge.ReadableMap
|
|
4
|
-
import com.facebook.react.uimanager.SimpleViewManager
|
|
5
3
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
-
import com.facebook.react.uimanager.
|
|
4
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
7
5
|
import com.revenuecat.purchases.ui.revenuecatui.ExperimentalPreviewRevenueCatUIPurchasesAPI
|
|
8
6
|
import com.revenuecat.purchases.ui.revenuecatui.views.PaywallView
|
|
9
7
|
|
|
@@ -19,7 +17,10 @@ internal class PaywallViewManager : BasePaywallViewManager<PaywallView>() {
|
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
override fun createViewInstance(themedReactContext: ThemedReactContext): PaywallView {
|
|
22
|
-
return PaywallView(themedReactContext)
|
|
20
|
+
return PaywallView(themedReactContext).also {
|
|
21
|
+
it.setPaywallListener(createPaywallListenerWrapper(themedReactContext, it))
|
|
22
|
+
it.setDismissHandler(getDismissHandler(themedReactContext, it))
|
|
23
|
+
}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
override fun createShadowNodeInstance(): PaywallViewShadowNode {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package com.revenuecat.purchases.react.ui
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableArray
|
|
4
|
+
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.facebook.react.bridge.WritableNativeArray
|
|
6
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
7
|
+
|
|
8
|
+
internal object RNPurchasesConverters {
|
|
9
|
+
|
|
10
|
+
@JvmStatic
|
|
11
|
+
@Suppress("UNCHECKED_CAST")
|
|
12
|
+
fun convertMapToWriteableMap(map: Map<String, *>): WritableMap {
|
|
13
|
+
val writableMap: WritableMap = WritableNativeMap()
|
|
14
|
+
for ((key, value) in map) {
|
|
15
|
+
when (value) {
|
|
16
|
+
null -> writableMap.putNull(key)
|
|
17
|
+
is Boolean -> writableMap.putBoolean(key, value)
|
|
18
|
+
is Int -> writableMap.putInt(key, value)
|
|
19
|
+
is Long -> writableMap.putDouble(key, value.toDouble())
|
|
20
|
+
is Double -> writableMap.putDouble(key, value)
|
|
21
|
+
is String -> writableMap.putString(key, value)
|
|
22
|
+
is Map<*, *> -> writableMap.putMap(key, convertMapToWriteableMap(value as Map<String, *>))
|
|
23
|
+
is Array<*> -> writableMap.putArray(key, convertArrayToWritableArray(value as Array<Any?>))
|
|
24
|
+
is List<*> -> writableMap.putArray(key, convertArrayToWritableArray(value.toTypedArray()))
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return writableMap
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Suppress("UNCHECKED_CAST")
|
|
31
|
+
private fun convertArrayToWritableArray(array: Array<Any?>): WritableArray {
|
|
32
|
+
val writableArray: WritableArray = WritableNativeArray()
|
|
33
|
+
for (item in array) {
|
|
34
|
+
when (item) {
|
|
35
|
+
null -> writableArray.pushNull()
|
|
36
|
+
is Boolean -> writableArray.pushBoolean(item)
|
|
37
|
+
is Int -> writableArray.pushInt(item)
|
|
38
|
+
is Long -> writableArray.pushDouble(item.toDouble())
|
|
39
|
+
is Double -> writableArray.pushDouble(item)
|
|
40
|
+
is String -> writableArray.pushString(item)
|
|
41
|
+
is Map<*, *> -> writableArray.pushMap(convertMapToWriteableMap(item as Map<String, *>))
|
|
42
|
+
is Array<*> -> writableArray.pushArray(convertArrayToWritableArray(item as Array<Any?>))
|
|
43
|
+
is List<*> -> writableArray.pushArray(convertArrayToWritableArray(item.toTypedArray()))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return writableArray
|
|
47
|
+
}
|
|
48
|
+
}
|
package/ios/PaywallViewManager.m
CHANGED
|
@@ -12,22 +12,55 @@
|
|
|
12
12
|
@import PurchasesHybridCommonUI;
|
|
13
13
|
@import RevenueCatUI;
|
|
14
14
|
|
|
15
|
+
@interface PaywallViewManager ()
|
|
16
|
+
|
|
17
|
+
@property (nonatomic, strong) id proxyIfAvailable;
|
|
18
|
+
|
|
19
|
+
@end
|
|
20
|
+
|
|
15
21
|
@implementation PaywallViewManager
|
|
16
22
|
|
|
17
23
|
RCT_EXPORT_VIEW_PROPERTY(options, NSDictionary);
|
|
18
24
|
|
|
25
|
+
RCT_EXPORT_VIEW_PROPERTY(onPurchaseCompleted, RCTDirectEventBlock)
|
|
26
|
+
RCT_EXPORT_VIEW_PROPERTY(onPurchaseError, RCTDirectEventBlock)
|
|
27
|
+
RCT_EXPORT_VIEW_PROPERTY(onPurchaseCancelled, RCTDirectEventBlock)
|
|
28
|
+
RCT_EXPORT_VIEW_PROPERTY(onRestoreCompleted, RCTDirectEventBlock)
|
|
29
|
+
RCT_EXPORT_VIEW_PROPERTY(onRestoreError, RCTDirectEventBlock)
|
|
30
|
+
RCT_EXPORT_VIEW_PROPERTY(onDismiss, RCTDirectEventBlock)
|
|
31
|
+
|
|
19
32
|
RCT_EXPORT_MODULE(Paywall)
|
|
20
33
|
|
|
34
|
+
- (instancetype)init {
|
|
35
|
+
if ((self = [super init])) {
|
|
36
|
+
if (@available(iOS 15.0, *)) {
|
|
37
|
+
_proxyIfAvailable = [[PaywallProxy alloc] init];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return self;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (PaywallProxy *)proxy API_AVAILABLE(ios(15.0)){
|
|
45
|
+
return (PaywallProxy *)self.proxyIfAvailable;
|
|
46
|
+
}
|
|
47
|
+
|
|
21
48
|
- (UIView *)view
|
|
22
49
|
{
|
|
23
50
|
if (@available(iOS 15.0, *)) {
|
|
24
|
-
|
|
51
|
+
UIViewController *viewController = [self.proxy createPaywallView];
|
|
52
|
+
PaywallViewWrapper *wrapper = [[PaywallViewWrapper alloc] initWithPaywallViewController:viewController];
|
|
53
|
+
self.proxy.delegate = wrapper;
|
|
25
54
|
|
|
26
|
-
return
|
|
55
|
+
return wrapper;
|
|
27
56
|
} else {
|
|
28
57
|
NSLog(@"Error: attempted to present paywalls on unsupported iOS version.");
|
|
29
58
|
return nil;
|
|
30
59
|
}
|
|
31
60
|
}
|
|
32
61
|
|
|
62
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
63
|
+
return YES;
|
|
64
|
+
}
|
|
65
|
+
|
|
33
66
|
@end
|
package/ios/PaywallViewWrapper.h
CHANGED
|
@@ -6,10 +6,19 @@
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
#import <UIKit/UIKit.h>
|
|
9
|
+
#import <React/RCTComponent.h>
|
|
10
|
+
@import PurchasesHybridCommonUI;
|
|
9
11
|
|
|
10
12
|
NS_ASSUME_NONNULL_BEGIN
|
|
11
13
|
|
|
12
|
-
@interface PaywallViewWrapper : UIView
|
|
14
|
+
@interface PaywallViewWrapper : UIView <RCPaywallViewControllerDelegateWrapper>
|
|
15
|
+
|
|
16
|
+
@property (nonatomic, copy) RCTDirectEventBlock onPurchaseCompleted;
|
|
17
|
+
@property (nonatomic, copy) RCTDirectEventBlock onPurchaseError;
|
|
18
|
+
@property (nonatomic, copy) RCTDirectEventBlock onPurchaseCancelled;
|
|
19
|
+
@property (nonatomic, copy) RCTDirectEventBlock onRestoreCompleted;
|
|
20
|
+
@property (nonatomic, copy) RCTDirectEventBlock onRestoreError;
|
|
21
|
+
@property (nonatomic, copy) RCTDirectEventBlock onDismiss;
|
|
13
22
|
|
|
14
23
|
- (instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE;
|
|
15
24
|
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
|
package/ios/PaywallViewWrapper.m
CHANGED
|
@@ -6,24 +6,26 @@
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
#import "PaywallViewWrapper.h"
|
|
9
|
-
|
|
10
9
|
#import "UIView+Extensions.h"
|
|
11
10
|
|
|
12
11
|
@import PurchasesHybridCommonUI;
|
|
13
12
|
@import RevenueCatUI;
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
static NSString *const KeyCustomerInfo = @"customerInfo";
|
|
15
|
+
static NSString *const KeyStoreTransaction = @"storeTransaction";
|
|
16
|
+
static NSString *const KeyError = @"error";
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
API_AVAILABLE(ios(15.0))
|
|
19
|
+
@interface PaywallViewWrapper ()
|
|
19
20
|
|
|
20
|
-
@property
|
|
21
|
+
@property(strong, nonatomic) RCPaywallViewController *paywallViewController;
|
|
22
|
+
@property(nonatomic) BOOL addedToHierarchy;
|
|
21
23
|
|
|
22
24
|
@end
|
|
23
25
|
|
|
24
26
|
@implementation PaywallViewWrapper
|
|
25
27
|
|
|
26
|
-
- (instancetype)initWithPaywallViewController:(RCPaywallViewController *)paywallViewController API_AVAILABLE(ios(15.0)){
|
|
28
|
+
- (instancetype)initWithPaywallViewController:(RCPaywallViewController *)paywallViewController API_AVAILABLE(ios(15.0)) {
|
|
27
29
|
NSParameterAssert(paywallViewController);
|
|
28
30
|
|
|
29
31
|
if ((self = [super initWithFrame:paywallViewController.view.bounds])) {
|
|
@@ -35,7 +37,7 @@ API_AVAILABLE(ios(15.0))
|
|
|
35
37
|
|
|
36
38
|
- (void)layoutSubviews {
|
|
37
39
|
[super layoutSubviews];
|
|
38
|
-
|
|
40
|
+
|
|
39
41
|
// Need to wait for this view to be in the hierarchy to look for the parent UIVC.
|
|
40
42
|
// This is required to add a SwiftUI `UIHostingController` to the hierarchy in a way that allows
|
|
41
43
|
// UIKit to read properties from the environment, like traits and safe area.
|
|
@@ -73,4 +75,46 @@ API_AVAILABLE(ios(15.0))
|
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
|
|
78
|
+
- (void)paywallViewControllerDidStartPurchase:(RCPaywallViewController *)controller API_AVAILABLE(ios(15.0)) {
|
|
79
|
+
// TODO: We need to send the package being purchased to match Android
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
- (void)paywallViewController:(RCPaywallViewController *)controller
|
|
83
|
+
didFinishPurchasingWithCustomerInfoDictionary:(NSDictionary *)customerInfoDictionary
|
|
84
|
+
transactionDictionary:(NSDictionary *)transactionDictionary API_AVAILABLE(ios(15.0)) {
|
|
85
|
+
self.onPurchaseCompleted(@{
|
|
86
|
+
KeyCustomerInfo: customerInfoDictionary,
|
|
87
|
+
KeyStoreTransaction: transactionDictionary,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
- (void)paywallViewControllerDidCancelPurchase:(RCPaywallViewController *)controller API_AVAILABLE(ios(15.0)) {
|
|
92
|
+
self.onPurchaseCancelled(nil);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
- (void)paywallViewController:(RCPaywallViewController *)controller
|
|
96
|
+
didFailPurchasingWithErrorDictionary:(NSDictionary *)errorDictionary API_AVAILABLE(ios(15.0)) {
|
|
97
|
+
self.onPurchaseError(@{
|
|
98
|
+
KeyError: errorDictionary
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
- (void)paywallViewController:(RCPaywallViewController *)controller
|
|
103
|
+
didFinishRestoringWithCustomerInfoDictionary:(NSDictionary *)customerInfoDictionary API_AVAILABLE(ios(15.0)) {
|
|
104
|
+
self.onRestoreCompleted(@{
|
|
105
|
+
KeyCustomerInfo: customerInfoDictionary
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
- (void)paywallViewController:(RCPaywallViewController *)controller
|
|
110
|
+
didFailRestoringWithErrorDictionary:(NSDictionary *)errorDictionary API_AVAILABLE(ios(15.0)) {
|
|
111
|
+
self.onRestoreError(@{
|
|
112
|
+
KeyError: errorDictionary
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- (void)paywallViewControllerWasDismissed:(RCPaywallViewController *)controller API_AVAILABLE(ios(15.0)) {
|
|
117
|
+
self.onDismiss(nil);
|
|
118
|
+
}
|
|
119
|
+
|
|
76
120
|
@end
|
|
@@ -17,8 +17,6 @@
|
|
|
17
17
|
#import <React/RCTUIManager.h>
|
|
18
18
|
#import <React/RCTBridge.h>
|
|
19
19
|
#import <React/RCTRootViewDelegate.h>
|
|
20
|
-
#import <React/RCTEventEmitter.h>
|
|
21
|
-
|
|
22
20
|
|
|
23
21
|
NS_ASSUME_NONNULL_BEGIN
|
|
24
22
|
|
|
@@ -31,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
31
29
|
|
|
32
30
|
NS_ASSUME_NONNULL_END
|
|
33
31
|
|
|
34
|
-
@interface FooterViewWrapper ()
|
|
32
|
+
@interface FooterViewWrapper ()
|
|
35
33
|
|
|
36
34
|
@property (strong, nonatomic) RCTBridge *bridge;
|
|
37
35
|
|
|
@@ -53,8 +51,8 @@ NS_ASSUME_NONNULL_END
|
|
|
53
51
|
// Get the safe area insets, for example
|
|
54
52
|
UIEdgeInsets safeAreaInsets = self.safeAreaInsets;
|
|
55
53
|
|
|
56
|
-
// TODO: figure out a better way of sending event, since this is deprecated
|
|
57
|
-
// It's probably better to create a singleton from the module that this view manager can call and use to send events
|
|
54
|
+
// TODO: figure out a better way of sending event, since this is deprecated
|
|
55
|
+
// It's probably better to create a singleton from the module that this view manager can call and use to send events
|
|
58
56
|
#pragma clang diagnostic push
|
|
59
57
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
60
58
|
[self.bridge.eventDispatcher sendAppEventWithName:safeAreaInsetsDidChangeEvent
|
|
@@ -65,7 +63,7 @@ NS_ASSUME_NONNULL_END
|
|
|
65
63
|
#pragma clang diagnostic pop
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
- (void)paywallViewController:(RCPaywallViewController *)controller didChangeSizeTo:(CGSize)size API_AVAILABLE(ios(15.0)){
|
|
66
|
+
- (void)paywallViewController:(RCPaywallViewController *)controller didChangeSizeTo:(CGSize)size API_AVAILABLE(ios(15.0)) {
|
|
69
67
|
[_bridge.uiManager setIntrinsicContentSize:CGSizeMake(UIViewNoIntrinsicMetric, size.height) forView:self];
|
|
70
68
|
}
|
|
71
69
|
|
|
@@ -81,6 +79,13 @@ NS_ASSUME_NONNULL_END
|
|
|
81
79
|
|
|
82
80
|
RCT_EXPORT_VIEW_PROPERTY(options, NSDictionary);
|
|
83
81
|
|
|
82
|
+
RCT_EXPORT_VIEW_PROPERTY(onPurchaseCompleted, RCTDirectEventBlock)
|
|
83
|
+
RCT_EXPORT_VIEW_PROPERTY(onPurchaseError, RCTDirectEventBlock)
|
|
84
|
+
RCT_EXPORT_VIEW_PROPERTY(onPurchaseCancelled, RCTDirectEventBlock)
|
|
85
|
+
RCT_EXPORT_VIEW_PROPERTY(onRestoreCompleted, RCTDirectEventBlock)
|
|
86
|
+
RCT_EXPORT_VIEW_PROPERTY(onRestoreError, RCTDirectEventBlock)
|
|
87
|
+
RCT_EXPORT_VIEW_PROPERTY(onDismiss, RCTDirectEventBlock)
|
|
88
|
+
|
|
84
89
|
RCT_EXPORT_MODULE(RCPaywallFooterView)
|
|
85
90
|
|
|
86
91
|
- (instancetype)init {
|
|
@@ -101,7 +106,7 @@ RCT_EXPORT_MODULE(RCPaywallFooterView)
|
|
|
101
106
|
{
|
|
102
107
|
if (@available(iOS 15.0, *)) {
|
|
103
108
|
UIViewController *footerViewController = [self.proxy createFooterPaywallView];
|
|
104
|
-
FooterViewWrapper *wrapper = [[FooterViewWrapper alloc] initWithPaywallViewController:footerViewController
|
|
109
|
+
FooterViewWrapper *wrapper = [[FooterViewWrapper alloc] initWithPaywallViewController:footerViewController
|
|
105
110
|
bridge:self.bridge];
|
|
106
111
|
self.proxy.delegate = wrapper;
|
|
107
112
|
|
package/lib/commonjs/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var _purchasesTypescriptInternal = require("@revenuecat/purchases-typescript-int
|
|
|
15
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
19
18
|
const LINKING_ERROR = `The package 'react-native-purchases-ui' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
20
19
|
ios: "- You have run 'pod install'\n",
|
|
21
20
|
default: ''
|
|
@@ -83,15 +82,39 @@ class RevenueCatUI {
|
|
|
83
82
|
}) {
|
|
84
83
|
return RNPaywalls.presentPaywallIfNeeded(requiredEntitlementIdentifier, (offering === null || offering === void 0 ? void 0 : offering.identifier) ?? null, displayCloseButton);
|
|
85
84
|
}
|
|
86
|
-
static Paywall =
|
|
85
|
+
static Paywall = ({
|
|
86
|
+
style,
|
|
87
|
+
children,
|
|
88
|
+
options,
|
|
89
|
+
onPurchaseCompleted,
|
|
90
|
+
onPurchaseError,
|
|
91
|
+
onPurchaseCancelled,
|
|
92
|
+
onRestoreCompleted,
|
|
93
|
+
onRestoreError,
|
|
94
|
+
onDismiss
|
|
95
|
+
}) => /*#__PURE__*/_react.default.createElement(InternalPaywall, {
|
|
96
|
+
options: options,
|
|
97
|
+
children: children,
|
|
98
|
+
onPurchaseCompleted: event => onPurchaseCompleted && onPurchaseCompleted(event.nativeEvent),
|
|
99
|
+
onPurchaseError: event => onPurchaseError && onPurchaseError(event.nativeEvent),
|
|
100
|
+
onPurchaseCancelled: () => onPurchaseCancelled && onPurchaseCancelled(),
|
|
101
|
+
onRestoreCompleted: event => onRestoreCompleted && onRestoreCompleted(event.nativeEvent),
|
|
102
|
+
onRestoreError: event => onRestoreError && onRestoreError(event.nativeEvent),
|
|
103
|
+
onDismiss: () => onDismiss && onDismiss(),
|
|
87
104
|
style: [{
|
|
88
105
|
flex: 1
|
|
89
|
-
},
|
|
90
|
-
})
|
|
106
|
+
}, style]
|
|
107
|
+
});
|
|
91
108
|
static PaywallFooterContainerView = ({
|
|
92
109
|
style,
|
|
93
110
|
children,
|
|
94
|
-
options
|
|
111
|
+
options,
|
|
112
|
+
onPurchaseCompleted,
|
|
113
|
+
onPurchaseError,
|
|
114
|
+
onPurchaseCancelled,
|
|
115
|
+
onRestoreCompleted,
|
|
116
|
+
onRestoreError,
|
|
117
|
+
onDismiss
|
|
95
118
|
}) => {
|
|
96
119
|
// We use 20 as the default paddingBottom because that's the corner radius in the Android native SDK.
|
|
97
120
|
// We also listen to safeAreaInsetsDidChange which is only sent from iOS and which is triggered when the
|
|
@@ -122,7 +145,13 @@ class RevenueCatUI {
|
|
|
122
145
|
style: {
|
|
123
146
|
marginTop: -20
|
|
124
147
|
},
|
|
125
|
-
options: options
|
|
148
|
+
options: options,
|
|
149
|
+
onPurchaseCompleted: event => onPurchaseCompleted && onPurchaseCompleted(event.nativeEvent),
|
|
150
|
+
onPurchaseError: event => onPurchaseError && onPurchaseError(event.nativeEvent),
|
|
151
|
+
onPurchaseCancelled: () => onPurchaseCancelled && onPurchaseCancelled(),
|
|
152
|
+
onRestoreCompleted: event => onRestoreCompleted && onRestoreCompleted(event.nativeEvent),
|
|
153
|
+
onRestoreError: event => onRestoreError && onRestoreError(event.nativeEvent),
|
|
154
|
+
onDismiss: () => onDismiss && onDismiss()
|
|
126
155
|
}));
|
|
127
156
|
};
|
|
128
157
|
}
|
|
@@ -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","
|
|
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","LINKING_ERROR","Platform","select","ios","RNPaywalls","NativeModules","Error","eventEmitter","NativeEventEmitter","InternalPaywall","UIManager","getViewManagerConfig","requireNativeComponent","InternalPaywallFooterView","RevenueCatUI","Defaults","PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON","PAYWALL_RESULT","presentPaywall","offering","displayCloseButton","identifier","presentPaywallIfNeeded","requiredEntitlementIdentifier","Paywall","style","children","options","onPurchaseCompleted","onPurchaseError","onPurchaseCancelled","onRestoreCompleted","onRestoreError","onDismiss","createElement","event","nativeEvent","flex","PaywallFooterContainerView","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;AAMA,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,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CA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KAAK,CAACC,WAAW,CAAE;MACvFN,mBAAmB,EAAEA,CAAA,KAAMA,mBAAmB,IAAIA,mBAAmB,CAAC,CAAE;MACxEC,kBAAkB,EAAGI,KAAU,IAAKJ,kBAAkB,IAAIA,kBAAkB,CAACI,KAAK,CAACC,WAAW,CAAE;MAChGJ,cAAc,EAAGG,KAAU,IAAKH,cAAc,IAAIA,cAAc,CAACG,KAAK,CAACC,WAAW,CAAE;MACpFH,SAAS,EAAEA,CAAA,KAAMA,SAAS,IAAIA,SAAS,CAAC;IAAE,CAC3C,CACG,CAAC;EAEX,CAAC;AACH;AAACoB,OAAA,CAAApE,OAAA,GAAA6B,YAAA"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
1
|
import { NativeEventEmitter, NativeModules, Platform, requireNativeComponent, ScrollView, UIManager, View } from "react-native";
|
|
3
2
|
import { PAYWALL_RESULT } from "@revenuecat/purchases-typescript-internal";
|
|
4
3
|
import React, { useEffect, useState } from "react";
|
|
@@ -70,15 +69,39 @@ export default class RevenueCatUI {
|
|
|
70
69
|
}) {
|
|
71
70
|
return RNPaywalls.presentPaywallIfNeeded(requiredEntitlementIdentifier, (offering === null || offering === void 0 ? void 0 : offering.identifier) ?? null, displayCloseButton);
|
|
72
71
|
}
|
|
73
|
-
static Paywall =
|
|
72
|
+
static Paywall = ({
|
|
73
|
+
style,
|
|
74
|
+
children,
|
|
75
|
+
options,
|
|
76
|
+
onPurchaseCompleted,
|
|
77
|
+
onPurchaseError,
|
|
78
|
+
onPurchaseCancelled,
|
|
79
|
+
onRestoreCompleted,
|
|
80
|
+
onRestoreError,
|
|
81
|
+
onDismiss
|
|
82
|
+
}) => /*#__PURE__*/React.createElement(InternalPaywall, {
|
|
83
|
+
options: options,
|
|
84
|
+
children: children,
|
|
85
|
+
onPurchaseCompleted: event => onPurchaseCompleted && onPurchaseCompleted(event.nativeEvent),
|
|
86
|
+
onPurchaseError: event => onPurchaseError && onPurchaseError(event.nativeEvent),
|
|
87
|
+
onPurchaseCancelled: () => onPurchaseCancelled && onPurchaseCancelled(),
|
|
88
|
+
onRestoreCompleted: event => onRestoreCompleted && onRestoreCompleted(event.nativeEvent),
|
|
89
|
+
onRestoreError: event => onRestoreError && onRestoreError(event.nativeEvent),
|
|
90
|
+
onDismiss: () => onDismiss && onDismiss(),
|
|
74
91
|
style: [{
|
|
75
92
|
flex: 1
|
|
76
|
-
},
|
|
77
|
-
})
|
|
93
|
+
}, style]
|
|
94
|
+
});
|
|
78
95
|
static PaywallFooterContainerView = ({
|
|
79
96
|
style,
|
|
80
97
|
children,
|
|
81
|
-
options
|
|
98
|
+
options,
|
|
99
|
+
onPurchaseCompleted,
|
|
100
|
+
onPurchaseError,
|
|
101
|
+
onPurchaseCancelled,
|
|
102
|
+
onRestoreCompleted,
|
|
103
|
+
onRestoreError,
|
|
104
|
+
onDismiss
|
|
82
105
|
}) => {
|
|
83
106
|
// We use 20 as the default paddingBottom because that's the corner radius in the Android native SDK.
|
|
84
107
|
// We also listen to safeAreaInsetsDidChange which is only sent from iOS and which is triggered when the
|
|
@@ -109,7 +132,13 @@ export default class RevenueCatUI {
|
|
|
109
132
|
style: {
|
|
110
133
|
marginTop: -20
|
|
111
134
|
},
|
|
112
|
-
options: options
|
|
135
|
+
options: options,
|
|
136
|
+
onPurchaseCompleted: event => onPurchaseCompleted && onPurchaseCompleted(event.nativeEvent),
|
|
137
|
+
onPurchaseError: event => onPurchaseError && onPurchaseError(event.nativeEvent),
|
|
138
|
+
onPurchaseCancelled: () => onPurchaseCancelled && onPurchaseCancelled(),
|
|
139
|
+
onRestoreCompleted: event => onRestoreCompleted && onRestoreCompleted(event.nativeEvent),
|
|
140
|
+
onRestoreError: event => onRestoreError && onRestoreError(event.nativeEvent),
|
|
141
|
+
onDismiss: () => onDismiss && onDismiss()
|
|
113
142
|
}));
|
|
114
143
|
};
|
|
115
144
|
}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","Platform","requireNativeComponent","ScrollView","UIManager","View","PAYWALL_RESULT","React","useEffect","useState","LINKING_ERROR","select","ios","default","RNPaywalls","Error","eventEmitter","InternalPaywall","getViewManagerConfig","InternalPaywallFooterView","RevenueCatUI","Defaults","PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON","presentPaywall","offering","displayCloseButton","identifier","presentPaywallIfNeeded","requiredEntitlementIdentifier","Paywall","
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","Platform","requireNativeComponent","ScrollView","UIManager","View","PAYWALL_RESULT","React","useEffect","useState","LINKING_ERROR","select","ios","default","RNPaywalls","Error","eventEmitter","InternalPaywall","getViewManagerConfig","InternalPaywallFooterView","RevenueCatUI","Defaults","PRESENT_PAYWALL_DISPLAY_CLOSE_BUTTON","presentPaywall","offering","displayCloseButton","identifier","presentPaywallIfNeeded","requiredEntitlementIdentifier","Paywall","style","children","options","onPurchaseCompleted","onPurchaseError","onPurchaseCancelled","onRestoreCompleted","onRestoreError","onDismiss","createElement","event","nativeEvent","flex","PaywallFooterContainerView","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,SAEEC,cAAc,QAGT,2CAA2C;AAClD,OAAOC,KAAK,IAAoBC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAElE,SAASH,cAAc,QAAQ,2CAA2C;AAE1E,MAA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cAAc,CAACG,KAAK,CAACC,WAAW,CAAE;MACpFH,SAAS,EAAEA,CAAA,KAAMA,SAAS,IAAIA,SAAS,CAAC;IAAE,CAC3C,CACG,CAAC;EAEX,CAAC;AACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type StyleProp, type ViewStyle } from "react-native";
|
|
2
|
-
import { PAYWALL_RESULT, type PurchasesOffering } from "@revenuecat/purchases-typescript-internal";
|
|
2
|
+
import { type CustomerInfo, PAYWALL_RESULT, type PurchasesError, type PurchasesOffering, type PurchasesStoreTransaction } 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
|
export interface PresentPaywallParams {
|
|
@@ -29,11 +29,41 @@ type FullScreenPaywallViewProps = {
|
|
|
29
29
|
style?: StyleProp<ViewStyle>;
|
|
30
30
|
children?: ReactNode;
|
|
31
31
|
options?: FullScreenPaywallViewOptions;
|
|
32
|
+
onPurchaseCompleted?: ({ customerInfo, storeTransaction }: {
|
|
33
|
+
customerInfo: CustomerInfo;
|
|
34
|
+
storeTransaction: PurchasesStoreTransaction;
|
|
35
|
+
}) => void;
|
|
36
|
+
onPurchaseError?: ({ error }: {
|
|
37
|
+
error: PurchasesError;
|
|
38
|
+
}) => void;
|
|
39
|
+
onPurchaseCancelled?: () => void;
|
|
40
|
+
onRestoreCompleted?: ({ customerInfo }: {
|
|
41
|
+
customerInfo: CustomerInfo;
|
|
42
|
+
}) => void;
|
|
43
|
+
onRestoreError?: ({ error }: {
|
|
44
|
+
error: PurchasesError;
|
|
45
|
+
}) => void;
|
|
46
|
+
onDismiss?: () => void;
|
|
32
47
|
};
|
|
33
48
|
type FooterPaywallViewProps = {
|
|
34
49
|
style?: StyleProp<ViewStyle>;
|
|
35
50
|
children?: ReactNode;
|
|
36
51
|
options?: FooterPaywallViewOptions;
|
|
52
|
+
onPurchaseCompleted?: ({ customerInfo, storeTransaction }: {
|
|
53
|
+
customerInfo: CustomerInfo;
|
|
54
|
+
storeTransaction: PurchasesStoreTransaction;
|
|
55
|
+
}) => void;
|
|
56
|
+
onPurchaseError?: ({ error }: {
|
|
57
|
+
error: PurchasesError;
|
|
58
|
+
}) => void;
|
|
59
|
+
onPurchaseCancelled?: () => void;
|
|
60
|
+
onRestoreCompleted?: ({ customerInfo }: {
|
|
61
|
+
customerInfo: CustomerInfo;
|
|
62
|
+
}) => void;
|
|
63
|
+
onRestoreError?: ({ error }: {
|
|
64
|
+
error: PurchasesError;
|
|
65
|
+
}) => void;
|
|
66
|
+
onDismiss?: () => void;
|
|
37
67
|
};
|
|
38
68
|
export default class RevenueCatUI {
|
|
39
69
|
private static Defaults;
|
|
@@ -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,
|
|
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,EACL,KAAK,YAAY,EACjB,cAAc,EAAE,KAAK,cAAc,EACnC,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC/B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AA6B3E,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,GAAG;IAChE;;OA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QAAC,gBAAgB,EAAE,yBAAyB,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/G,eAAe,CAAC,EAAE,CAAC,EAAC,KAAK,EAAC,EAAE;QAAE,KAAK,EAAE,cAAc,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/D,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,kBAAkB,CAAC,EAAE,CAAC,EAAC,YAAY,EAAC,EAAE;QAAE,YAAY,EAAE,YAAY,CAAA;KAAE,KAAK,IAAI,CAAC;IAC9E,cAAc,CAAC,EAAE,CAAC,EAAC,KAAK,EAAC,EAAE;QAAE,KAAK,EAAE,cAAc,CAAA;KAAE,KAAK,IAAI,CAAC;IAC9D,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,YAAY;IAE/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAEtB;IAED;;;;OAIG;IACH,OAAc,cAAc,wBAAkB;IAE9C;;;;;;;;;OASG;WACW,cAAc,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,0BAA0B,CAAC,CAoBzD;IAEF,OAAc,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAsDxE;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.
|
|
4
|
+
"version": "7.21.0",
|
|
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",
|
|
@@ -114,6 +114,6 @@
|
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
116
|
"@revenuecat/purchases-typescript-internal": "8.10.1",
|
|
117
|
-
"react-native-purchases": "7.
|
|
117
|
+
"react-native-purchases": "7.21.0"
|
|
118
118
|
}
|
|
119
119
|
}
|
package/src/index.tsx
CHANGED
|
@@ -9,7 +9,12 @@ import {
|
|
|
9
9
|
View,
|
|
10
10
|
type ViewStyle,
|
|
11
11
|
} from "react-native";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
type CustomerInfo,
|
|
14
|
+
PAYWALL_RESULT, type PurchasesError,
|
|
15
|
+
type PurchasesOffering,
|
|
16
|
+
type PurchasesStoreTransaction
|
|
17
|
+
} from "@revenuecat/purchases-typescript-internal";
|
|
13
18
|
import React, { type ReactNode, useEffect, useState } from "react";
|
|
14
19
|
|
|
15
20
|
export { PAYWALL_RESULT } from "@revenuecat/purchases-typescript-internal";
|
|
@@ -77,12 +82,30 @@ type FullScreenPaywallViewProps = {
|
|
|
77
82
|
style?: StyleProp<ViewStyle>;
|
|
78
83
|
children?: ReactNode;
|
|
79
84
|
options?: FullScreenPaywallViewOptions;
|
|
85
|
+
onPurchaseCompleted?: ({
|
|
86
|
+
customerInfo,
|
|
87
|
+
storeTransaction
|
|
88
|
+
}: { customerInfo: CustomerInfo, storeTransaction: PurchasesStoreTransaction }) => void;
|
|
89
|
+
onPurchaseError?: ({error}: { error: PurchasesError }) => void;
|
|
90
|
+
onPurchaseCancelled?: () => void;
|
|
91
|
+
onRestoreCompleted?: ({customerInfo}: { customerInfo: CustomerInfo }) => void;
|
|
92
|
+
onRestoreError?: ({error}: { error: PurchasesError }) => void;
|
|
93
|
+
onDismiss?: () => void;
|
|
80
94
|
};
|
|
81
95
|
|
|
82
96
|
type FooterPaywallViewProps = {
|
|
83
97
|
style?: StyleProp<ViewStyle>;
|
|
84
98
|
children?: ReactNode;
|
|
85
99
|
options?: FooterPaywallViewOptions;
|
|
100
|
+
onPurchaseCompleted?: ({
|
|
101
|
+
customerInfo,
|
|
102
|
+
storeTransaction
|
|
103
|
+
}: { customerInfo: CustomerInfo, storeTransaction: PurchasesStoreTransaction }) => void;
|
|
104
|
+
onPurchaseError?: ({error}: { error: PurchasesError }) => void;
|
|
105
|
+
onPurchaseCancelled?: () => void;
|
|
106
|
+
onRestoreCompleted?: ({customerInfo}: { customerInfo: CustomerInfo }) => void;
|
|
107
|
+
onRestoreError?: ({error}: { error: PurchasesError }) => void;
|
|
108
|
+
onDismiss?: () => void;
|
|
86
109
|
};
|
|
87
110
|
|
|
88
111
|
export default class RevenueCatUI {
|
|
@@ -136,11 +159,39 @@ export default class RevenueCatUI {
|
|
|
136
159
|
return RNPaywalls.presentPaywallIfNeeded(requiredEntitlementIdentifier, offering?.identifier ?? null, displayCloseButton)
|
|
137
160
|
}
|
|
138
161
|
|
|
139
|
-
public static Paywall: React.FC<FullScreenPaywallViewProps> = (
|
|
140
|
-
|
|
162
|
+
public static Paywall: React.FC<FullScreenPaywallViewProps> = ({
|
|
163
|
+
style,
|
|
164
|
+
children,
|
|
165
|
+
options,
|
|
166
|
+
onPurchaseCompleted,
|
|
167
|
+
onPurchaseError,
|
|
168
|
+
onPurchaseCancelled,
|
|
169
|
+
onRestoreCompleted,
|
|
170
|
+
onRestoreError,
|
|
171
|
+
onDismiss,
|
|
172
|
+
}) => (
|
|
173
|
+
<InternalPaywall options={options}
|
|
174
|
+
children={children}
|
|
175
|
+
onPurchaseCompleted={(event: any) => onPurchaseCompleted && onPurchaseCompleted(event.nativeEvent)}
|
|
176
|
+
onPurchaseError={(event: any) => onPurchaseError && onPurchaseError(event.nativeEvent)}
|
|
177
|
+
onPurchaseCancelled={() => onPurchaseCancelled && onPurchaseCancelled()}
|
|
178
|
+
onRestoreCompleted={(event: any) => onRestoreCompleted && onRestoreCompleted(event.nativeEvent)}
|
|
179
|
+
onRestoreError={(event: any) => onRestoreError && onRestoreError(event.nativeEvent)}
|
|
180
|
+
onDismiss={() => onDismiss && onDismiss()}
|
|
181
|
+
style={[{flex: 1}, style]}/>
|
|
141
182
|
);
|
|
142
183
|
|
|
143
|
-
public static PaywallFooterContainerView: React.FC<FooterPaywallViewProps> = ({
|
|
184
|
+
public static PaywallFooterContainerView: React.FC<FooterPaywallViewProps> = ({
|
|
185
|
+
style,
|
|
186
|
+
children,
|
|
187
|
+
options,
|
|
188
|
+
onPurchaseCompleted,
|
|
189
|
+
onPurchaseError,
|
|
190
|
+
onPurchaseCancelled,
|
|
191
|
+
onRestoreCompleted,
|
|
192
|
+
onRestoreError,
|
|
193
|
+
onDismiss,
|
|
194
|
+
}) => {
|
|
144
195
|
// We use 20 as the default paddingBottom because that's the corner radius in the Android native SDK.
|
|
145
196
|
// We also listen to safeAreaInsetsDidChange which is only sent from iOS and which is triggered when the
|
|
146
197
|
// safe area insets change. Not adding this extra padding on iOS will cause the content of the scrollview
|
|
@@ -172,7 +223,16 @@ export default class RevenueCatUI {
|
|
|
172
223
|
{children}
|
|
173
224
|
</ScrollView>
|
|
174
225
|
{/*Adding negative margin to the footer view to make it overlap with the extra padding of the scroll*/}
|
|
175
|
-
<InternalPaywallFooterView
|
|
226
|
+
<InternalPaywallFooterView
|
|
227
|
+
style={{marginTop: -20}}
|
|
228
|
+
options={options}
|
|
229
|
+
onPurchaseCompleted={(event: any) => onPurchaseCompleted && onPurchaseCompleted(event.nativeEvent)}
|
|
230
|
+
onPurchaseError={(event: any) => onPurchaseError && onPurchaseError(event.nativeEvent)}
|
|
231
|
+
onPurchaseCancelled={() => onPurchaseCancelled && onPurchaseCancelled()}
|
|
232
|
+
onRestoreCompleted={(event: any) => onRestoreCompleted && onRestoreCompleted(event.nativeEvent)}
|
|
233
|
+
onRestoreError={(event: any) => onRestoreError && onRestoreError(event.nativeEvent)}
|
|
234
|
+
onDismiss={() => onDismiss && onDismiss()}
|
|
235
|
+
/>
|
|
176
236
|
</View>
|
|
177
237
|
);
|
|
178
238
|
};
|