@umituz/react-native-subscription 2.35.22 → 2.35.23

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.22",
3
+ "version": "2.35.23",
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,8 +2,8 @@ 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";
6
5
  import { UserSwitchMutex } from "./UserSwitchMutex";
6
+ import { getPremiumEntitlement } from "../../core/types";
7
7
 
8
8
  declare const __DEV__: boolean;
9
9
 
@@ -151,7 +151,38 @@ export async function handleInitialConfiguration(
151
151
  });
152
152
  }
153
153
 
154
- await syncPremiumStatus(deps.config, currentUserId, customerInfo);
154
+ // Sync premium status via callback (if configured)
155
+ if (deps.config.onPremiumStatusChanged) {
156
+ try {
157
+ const premiumEntitlement = getPremiumEntitlement(
158
+ customerInfo,
159
+ deps.config.entitlementIdentifier
160
+ );
161
+
162
+ if (premiumEntitlement) {
163
+ await deps.config.onPremiumStatusChanged(
164
+ currentUserId,
165
+ true,
166
+ premiumEntitlement.productIdentifier,
167
+ premiumEntitlement.expirationDate ?? undefined,
168
+ premiumEntitlement.willRenew,
169
+ premiumEntitlement.periodType as "NORMAL" | "INTRO" | "TRIAL" | undefined
170
+ );
171
+ } else {
172
+ await deps.config.onPremiumStatusChanged(
173
+ currentUserId,
174
+ false,
175
+ undefined,
176
+ undefined,
177
+ undefined,
178
+ undefined
179
+ );
180
+ }
181
+ } catch (error) {
182
+ // Log error but don't fail initialization
183
+ console.error('[UserSwitchHandler] Premium status sync callback failed:', error);
184
+ }
185
+ }
155
186
 
156
187
  return buildSuccessResult(deps, customerInfo, offerings);
157
188
  } catch (error) {