@umituz/react-native-subscription 2.35.1 → 2.35.3

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.35.1",
3
+ "version": "2.35.3",
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",
@@ -2,6 +2,7 @@ import Purchases, { type CustomerInfo } from "react-native-purchases";
2
2
  import type { InitializeResult } from "../../../../shared/application/ports/IRevenueCatService";
3
3
  import type { InitializerDeps } from "./RevenueCatInitializer.types";
4
4
  import { FAILED_INITIALIZATION_RESULT } from "./initializerConstants";
5
+ import { syncPremiumStatus } from "../../../subscription/infrastructure/utils/PremiumStatusSyncer";
5
6
 
6
7
  declare const __DEV__: boolean;
7
8
 
@@ -118,8 +119,9 @@ export async function handleInitialConfiguration(
118
119
  Purchases.getOfferings(),
119
120
  ]);
120
121
 
122
+ const currentUserId = await Purchases.getAppUserID();
123
+
121
124
  if (typeof __DEV__ !== 'undefined' && __DEV__) {
122
- const currentUserId = await Purchases.getAppUserID();
123
125
  console.log('[UserSwitchHandler] ✅ Initial configuration completed:', {
124
126
  revenueCatUserId: currentUserId,
125
127
  activeEntitlements: Object.keys(customerInfo.entitlements.active),
@@ -127,6 +129,8 @@ export async function handleInitialConfiguration(
127
129
  });
128
130
  }
129
131
 
132
+ await syncPremiumStatus(deps.config, currentUserId, customerInfo);
133
+
130
134
  return buildSuccessResult(deps, customerInfo, offerings);
131
135
  } catch (error) {
132
136
  console.error('[UserSwitchHandler] SDK configuration failed', {
@@ -14,7 +14,7 @@ export const executeFeatureAction = (
14
14
  isWaitingForAuthCreditsRef: MutableRefObject<boolean>,
15
15
  isWaitingForPurchaseRef: MutableRefObject<boolean>,
16
16
  isCreditsLoadedRef: MutableRefObject<boolean>
17
- ): void => {
17
+ ): boolean => {
18
18
  if (typeof __DEV__ !== "undefined" && __DEV__) {
19
19
  console.log("[FeatureGate] executeFeatureAction called:", {
20
20
  isAuthenticated,
@@ -58,7 +58,7 @@ export const executeFeatureAction = (
58
58
  isWaitingForAuthCreditsRef.current = true;
59
59
  };
60
60
  onShowAuthModal(postAuthAction);
61
- return;
61
+ return false;
62
62
  }
63
63
 
64
64
  if (hasSubscriptionRef.current) {
@@ -66,7 +66,7 @@ export const executeFeatureAction = (
66
66
  console.log("[FeatureGate] User has subscription, executing action");
67
67
  }
68
68
  action();
69
- return;
69
+ return true;
70
70
  }
71
71
 
72
72
  if (creditBalanceRef.current < requiredCreditsRef.current) {
@@ -76,11 +76,12 @@ export const executeFeatureAction = (
76
76
  pendingActionRef.current = action;
77
77
  isWaitingForPurchaseRef.current = true;
78
78
  onShowPaywallRef.current(requiredCreditsRef.current);
79
- return;
79
+ return false;
80
80
  }
81
81
 
82
82
  if (typeof __DEV__ !== "undefined" && __DEV__) {
83
83
  console.log("[FeatureGate] User has enough credits, executing action");
84
84
  }
85
85
  action();
86
+ return true;
86
87
  };
@@ -113,8 +113,8 @@ export function useFeatureGate(params: UseFeatureGateParams): UseFeatureGateResu
113
113
  }, [creditBalance, hasSubscription]);
114
114
 
115
115
  const requireFeature = useCallback(
116
- (action: () => void | Promise<void>) => {
117
- executeFeatureAction(
116
+ (action: () => void | Promise<void>): boolean => {
117
+ return executeFeatureAction(
118
118
  action,
119
119
  isAuthenticated,
120
120
  onShowAuthModal,
@@ -9,7 +9,7 @@ export interface UseFeatureGateParams {
9
9
  }
10
10
 
11
11
  export interface UseFeatureGateResult {
12
- readonly requireFeature: (action: () => void | Promise<void>) => void;
12
+ readonly requireFeature: (action: () => void | Promise<void>) => boolean;
13
13
  readonly isAuthenticated: boolean;
14
14
  readonly hasSubscription: boolean;
15
15
  readonly hasCredits: boolean;