@umituz/react-native-subscription 2.31.10 → 2.31.12

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.31.10",
3
+ "version": "2.31.12",
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",
@@ -41,7 +41,7 @@ export const useCredits = (): UseCreditsResult => {
41
41
  throw new Error(result.error?.message || "Failed to fetch credits");
42
42
  }
43
43
 
44
- return result.data || null;
44
+ return result.data ?? null;
45
45
  },
46
46
  enabled: queryEnabled,
47
47
  gcTime: 0,
@@ -25,16 +25,16 @@ export class PurchaseStatusResolver {
25
25
  return {
26
26
  isPremium: true,
27
27
  expirationDate: toDate(entitlement.expirationDate),
28
- willRenew: entitlement.willRenew || false,
29
- productIdentifier: entitlement.productIdentifier || null,
30
- originalPurchaseDate: toDate(entitlement.originalPurchaseDate) || null,
31
- latestPurchaseDate: toDate(entitlement.latestPurchaseDate) || null,
28
+ willRenew: entitlement.willRenew ?? false,
29
+ productIdentifier: entitlement.productIdentifier ?? null,
30
+ originalPurchaseDate: toDate(entitlement.originalPurchaseDate) ?? null,
31
+ latestPurchaseDate: toDate(entitlement.latestPurchaseDate) ?? null,
32
32
  billingIssuesDetected: entitlement.billingIssueDetectedAt !== null && entitlement.billingIssueDetectedAt !== undefined,
33
- isSandbox: entitlement.isSandbox || false,
34
- periodType: entitlement.periodType || null,
35
- store: null, // Store info not available in entitlement type
36
- gracePeriodExpiresDate: null, // Grace period not available in entitlement type
37
- unsubscribeDetectedAt: toDate(entitlement.unsubscribeDetectedAt) || null,
33
+ isSandbox: entitlement.isSandbox ?? false,
34
+ periodType: entitlement.periodType ?? null,
35
+ store: null,
36
+ gracePeriodExpiresDate: null,
37
+ unsubscribeDetectedAt: toDate(entitlement.unsubscribeDetectedAt) ?? null,
38
38
  };
39
39
  }
40
40
 
@@ -91,12 +91,14 @@ export function useCustomerInfo(): UseCustomerInfoResult {
91
91
  setError(null);
92
92
  };
93
93
 
94
+ // Set ref BEFORE adding listener to ensure cleanup can always find it
94
95
  listenerRef.current = listener;
95
96
  Purchases.addCustomerInfoUpdateListener(listener);
96
97
 
97
98
  return () => {
98
99
  if (listenerRef.current) {
99
100
  Purchases.removeCustomerInfoUpdateListener(listenerRef.current);
101
+ listenerRef.current = null;
100
102
  }
101
103
  };
102
104
  }, [fetchCustomerInfo]);
@@ -75,18 +75,18 @@ export const useSubscriptionStatus = (): SubscriptionStatusResult => {
75
75
  const isLoading = status === "pending";
76
76
 
77
77
  return {
78
- isPremium: data?.isPremium || false,
79
- expirationDate: data?.expirationDate || null,
80
- willRenew: data?.willRenew || false,
81
- productIdentifier: data?.productIdentifier || null,
82
- originalPurchaseDate: data?.originalPurchaseDate || null,
83
- latestPurchaseDate: data?.latestPurchaseDate || null,
84
- billingIssuesDetected: data?.billingIssuesDetected || false,
85
- isSandbox: data?.isSandbox || false,
86
- periodType: data?.periodType || null,
87
- store: data?.store || null,
88
- gracePeriodExpiresDate: data?.gracePeriodExpiresDate || null,
89
- unsubscribeDetectedAt: data?.unsubscribeDetectedAt || null,
78
+ isPremium: data?.isPremium ?? false,
79
+ expirationDate: data?.expirationDate ?? null,
80
+ willRenew: data?.willRenew ?? false,
81
+ productIdentifier: data?.productIdentifier ?? null,
82
+ originalPurchaseDate: data?.originalPurchaseDate ?? null,
83
+ latestPurchaseDate: data?.latestPurchaseDate ?? null,
84
+ billingIssuesDetected: data?.billingIssuesDetected ?? false,
85
+ isSandbox: data?.isSandbox ?? false,
86
+ periodType: data?.periodType ?? null,
87
+ store: data?.store ?? null,
88
+ gracePeriodExpiresDate: data?.gracePeriodExpiresDate ?? null,
89
+ unsubscribeDetectedAt: data?.unsubscribeDetectedAt ?? null,
90
90
  isLoading,
91
91
  error: error as Error | null,
92
92
  refetch,