@umituz/react-native-subscription 2.37.16 → 2.37.18
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.37.
|
|
3
|
+
"version": "2.37.18",
|
|
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",
|
|
@@ -54,6 +54,13 @@ export const PaywallContainer: React.FC<PaywallContainerProps> = (props) => {
|
|
|
54
54
|
return createCreditAmountsFromPackages(packages, packageAllocations);
|
|
55
55
|
}, [providedCreditAmounts, packageAllocations, packages]);
|
|
56
56
|
|
|
57
|
+
// When using credit system, only show packages that have a credit allocation.
|
|
58
|
+
// This filters out lifetime/"unlimited" plans that aren't part of the credit model.
|
|
59
|
+
const displayPackages = useMemo(() => {
|
|
60
|
+
if (!creditAmounts || Object.keys(creditAmounts).length === 0) return packages;
|
|
61
|
+
return packages.filter((pkg) => creditAmounts[pkg.product.identifier] != null);
|
|
62
|
+
}, [packages, creditAmounts]);
|
|
63
|
+
|
|
57
64
|
if (!isVisible) return null;
|
|
58
65
|
|
|
59
66
|
return (
|
|
@@ -61,7 +68,7 @@ export const PaywallContainer: React.FC<PaywallContainerProps> = (props) => {
|
|
|
61
68
|
visible={isVisible}
|
|
62
69
|
onClose={handleClose}
|
|
63
70
|
translations={translations}
|
|
64
|
-
packages={
|
|
71
|
+
packages={displayPackages}
|
|
65
72
|
legalUrls={legalUrls}
|
|
66
73
|
features={features ? [...features] : undefined}
|
|
67
74
|
heroImage={heroImage}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Subscription Packages Hook
|
|
3
|
-
* TanStack query for fetching available packages
|
|
3
|
+
* TanStack query for fetching available packages (offerings)
|
|
4
4
|
* Auth info automatically read from @umituz/react-native-auth
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: Packages (offerings) are NOT user-specific - they're the same
|
|
7
|
+
* for all users. We only need RevenueCat to be initialized, not necessarily
|
|
8
|
+
* for a specific user. User-specific checks belong in useSubscriptionStatus.
|
|
5
9
|
*/
|
|
6
10
|
|
|
7
11
|
import { useQuery, useQueryClient } from "@umituz/react-native-design-system";
|
|
@@ -34,17 +38,14 @@ export const useSubscriptionPackages = () => {
|
|
|
34
38
|
initializationState.getSnapshot,
|
|
35
39
|
);
|
|
36
40
|
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
: initState.initialized || SubscriptionManager.isInitialized();
|
|
41
|
+
// Packages (offerings) are NOT user-specific - same for all users.
|
|
42
|
+
// We only need RevenueCat to be initialized at all.
|
|
43
|
+
// Use reactive state OR direct manager check for backwards compatibility.
|
|
44
|
+
const isInitialized = initState.initialized || SubscriptionManager.isInitialized();
|
|
42
45
|
|
|
43
46
|
const query = useQuery({
|
|
44
47
|
queryKey: [...SUBSCRIPTION_QUERY_KEYS.packages, userId ?? "anonymous"] as const,
|
|
45
48
|
queryFn: async () => {
|
|
46
|
-
// No side effects - just fetch packages
|
|
47
|
-
// Initialization is handled by BackgroundInitializer
|
|
48
49
|
return SubscriptionManager.getPackages();
|
|
49
50
|
},
|
|
50
51
|
enabled: isConfigured && isInitialized,
|
|
@@ -45,7 +45,10 @@ export function detectRenewal(
|
|
|
45
45
|
const newExpiration = new Date(newExpirationDate).getTime();
|
|
46
46
|
const previousExpiration = new Date(state.previousExpirationDate).getTime();
|
|
47
47
|
const productChanged = productId !== state.previousProductId;
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
// Guard against NaN from invalid date strings - treat as no extension
|
|
50
|
+
const expirationExtended =
|
|
51
|
+
!isNaN(newExpiration) && !isNaN(previousExpiration) && newExpiration > previousExpiration;
|
|
49
52
|
|
|
50
53
|
if (productChanged) {
|
|
51
54
|
const oldTier = getPackageTier(state.previousProductId);
|