@umituz/react-native-subscription 2.41.11 → 2.41.13
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.41.
|
|
3
|
+
"version": "2.41.13",
|
|
4
4
|
"description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
StatusBar,
|
|
15
15
|
} from "react-native";
|
|
16
16
|
import { useNavigation } from "@react-navigation/native";
|
|
17
|
+
import { usePremium } from "../../subscription/presentation/usePremium";
|
|
17
18
|
import { AtomicText, AtomicIcon, AtomicSpinner } from "@umituz/react-native-design-system/atoms";
|
|
18
19
|
import { useSafeAreaInsets } from "@umituz/react-native-design-system/safe-area";
|
|
19
20
|
import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
|
|
@@ -32,6 +33,9 @@ import { hasItems } from "../../../shared/utils/arrayUtils";
|
|
|
32
33
|
export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) => {
|
|
33
34
|
const navigation = useNavigation();
|
|
34
35
|
|
|
36
|
+
// Get purchase functions from usePremium as fallback
|
|
37
|
+
const { purchasePackage: premiumPurchase, restorePurchase: premiumRestore } = usePremium();
|
|
38
|
+
|
|
35
39
|
const {
|
|
36
40
|
onClose,
|
|
37
41
|
translations,
|
|
@@ -54,6 +58,21 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
|
|
|
54
58
|
const tokens = useAppDesignTokens();
|
|
55
59
|
const insets = useSafeAreaInsets();
|
|
56
60
|
|
|
61
|
+
// Use provided purchase functions or fall back to usePremium
|
|
62
|
+
const handlePurchasePackage = useCallback(async (pkg: any) => {
|
|
63
|
+
if (onPurchase) {
|
|
64
|
+
return await onPurchase(pkg);
|
|
65
|
+
}
|
|
66
|
+
return await premiumPurchase(pkg);
|
|
67
|
+
}, [onPurchase, premiumPurchase]);
|
|
68
|
+
|
|
69
|
+
const handleRestorePackages = useCallback(async () => {
|
|
70
|
+
if (onRestore) {
|
|
71
|
+
return await onRestore();
|
|
72
|
+
}
|
|
73
|
+
return await premiumRestore();
|
|
74
|
+
}, [onRestore, premiumRestore]);
|
|
75
|
+
|
|
57
76
|
// Default close handler using navigation
|
|
58
77
|
const handleClose = useCallback(() => {
|
|
59
78
|
if (onClose) {
|
|
@@ -72,8 +91,8 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
|
|
|
72
91
|
resetState
|
|
73
92
|
} = usePaywallActions({
|
|
74
93
|
packages,
|
|
75
|
-
onPurchase,
|
|
76
|
-
onRestore,
|
|
94
|
+
onPurchase: handlePurchasePackage,
|
|
95
|
+
onRestore: handleRestorePackages,
|
|
77
96
|
source,
|
|
78
97
|
onPurchaseSuccess,
|
|
79
98
|
onPurchaseError,
|
|
@@ -86,7 +105,7 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
|
|
|
86
105
|
return () => {
|
|
87
106
|
resetState();
|
|
88
107
|
};
|
|
89
|
-
}, [resetState]);
|
|
108
|
+
}, [resetState, handlePurchasePackage, handleRestorePackages]);
|
|
90
109
|
|
|
91
110
|
// Auto-select first package
|
|
92
111
|
useEffect(() => {
|
|
@@ -57,35 +57,6 @@ export function usePaywallOrchestrator({
|
|
|
57
57
|
const purchasedRef = useRef(false);
|
|
58
58
|
const hasNavigatedRef = useRef(false);
|
|
59
59
|
|
|
60
|
-
const handleClose = useCallback(async () => {
|
|
61
|
-
await closePostOnboardingPaywall();
|
|
62
|
-
closePaywall();
|
|
63
|
-
|
|
64
|
-
// Trigger feedback if user declined and isn't premium
|
|
65
|
-
if (!isPremium && !purchasedRef.current) {
|
|
66
|
-
setTimeout(() => setShowFeedback(true), 300);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
purchasedRef.current = false;
|
|
70
|
-
hasNavigatedRef.current = false;
|
|
71
|
-
|
|
72
|
-
if (navigation.canGoBack()) {
|
|
73
|
-
navigation.goBack();
|
|
74
|
-
}
|
|
75
|
-
}, [closePostOnboardingPaywall, closePaywall, isPremium, navigation, setShowFeedback]);
|
|
76
|
-
|
|
77
|
-
const handleSuccess = useCallback(async () => {
|
|
78
|
-
purchasedRef.current = true;
|
|
79
|
-
await markPaywallShown();
|
|
80
|
-
await closePostOnboardingPaywall();
|
|
81
|
-
|
|
82
|
-
onPurchaseSuccess?.();
|
|
83
|
-
|
|
84
|
-
if (navigation.canGoBack()) {
|
|
85
|
-
navigation.goBack();
|
|
86
|
-
}
|
|
87
|
-
}, [markPaywallShown, closePostOnboardingPaywall, onPurchaseSuccess, navigation]);
|
|
88
|
-
|
|
89
60
|
useEffect(() => {
|
|
90
61
|
if (!isNavReady || !isLocalizationReady) return;
|
|
91
62
|
|
|
@@ -108,19 +79,18 @@ export function usePaywallOrchestrator({
|
|
|
108
79
|
});
|
|
109
80
|
|
|
110
81
|
navigation.navigate("PaywallScreen", {
|
|
111
|
-
onClose: handleClose,
|
|
112
82
|
translations,
|
|
113
83
|
legalUrls,
|
|
114
84
|
features,
|
|
115
85
|
bestValueIdentifier,
|
|
116
86
|
creditsLabel,
|
|
117
|
-
onAuthRequired,
|
|
118
|
-
onPurchaseSuccess: handleSuccess,
|
|
119
87
|
heroImage,
|
|
120
88
|
source: shouldShowPostOnboarding ? "onboarding" : "manual",
|
|
121
89
|
packages,
|
|
122
90
|
onPurchase: purchasePackage,
|
|
123
91
|
onRestore: restorePurchase,
|
|
92
|
+
onPurchaseSuccess,
|
|
93
|
+
onAuthRequired,
|
|
124
94
|
});
|
|
125
95
|
|
|
126
96
|
if (shouldShowPostOnboarding) {
|
|
@@ -144,8 +114,6 @@ export function usePaywallOrchestrator({
|
|
|
144
114
|
isPremium,
|
|
145
115
|
showPaywall,
|
|
146
116
|
navigation,
|
|
147
|
-
handleClose,
|
|
148
|
-
handleSuccess,
|
|
149
117
|
translations,
|
|
150
118
|
legalUrls,
|
|
151
119
|
features,
|
|
@@ -157,7 +125,8 @@ export function usePaywallOrchestrator({
|
|
|
157
125
|
closePaywall,
|
|
158
126
|
bestValueIdentifier,
|
|
159
127
|
creditsLabel,
|
|
160
|
-
|
|
128
|
+
onPurchaseSuccess,
|
|
129
|
+
onAuthRequired,
|
|
161
130
|
]);
|
|
162
131
|
|
|
163
132
|
const completeOnboarding = useSubscriptionFlowStore((state) => state.completeOnboarding);
|