@umituz/react-native-subscription 2.27.32 → 2.27.33
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 +1 -1
- package/src/presentation/hooks/usePaywallVisibility.ts +0 -3
- package/src/presentation/hooks/usePremium.ts +0 -3
- package/src/revenuecat/infrastructure/handlers/PackageHandler.ts +9 -0
- package/src/revenuecat/infrastructure/managers/SubscriptionManager.ts +7 -0
- package/src/revenuecat/infrastructure/services/RevenueCatInitializer.ts +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.33",
|
|
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",
|
|
@@ -48,9 +48,6 @@ export interface UsePaywallVisibilityResult {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export function usePaywallVisibility(): UsePaywallVisibilityResult {
|
|
51
|
-
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
52
|
-
console.log('[usePaywallVisibility] Hook called');
|
|
53
|
-
}
|
|
54
51
|
const state = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
55
52
|
|
|
56
53
|
const setShowPaywall = useCallback((visible: boolean, source?: PurchaseSource) => {
|
|
@@ -33,9 +33,6 @@ export interface UsePremiumResult {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export const usePremium = (): UsePremiumResult => {
|
|
36
|
-
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
37
|
-
console.log('[usePremium] Hook called');
|
|
38
|
-
}
|
|
39
36
|
const { isPremium: subscriptionActive, isLoading: statusLoading } = useSubscriptionStatus();
|
|
40
37
|
const { credits, isLoading: creditsLoading } = useCredits();
|
|
41
38
|
|
|
@@ -30,7 +30,16 @@ export class PackageHandler {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
async fetchPackages(): Promise<PurchasesPackage[]> {
|
|
33
|
+
if (__DEV__) {
|
|
34
|
+
console.log('[DEBUG PackageHandler] fetchPackages called', {
|
|
35
|
+
hasService: !!this.service,
|
|
36
|
+
isInitialized: this.service?.isInitialized(),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
33
39
|
if (!this.service?.isInitialized()) {
|
|
40
|
+
if (__DEV__) {
|
|
41
|
+
console.log('[DEBUG PackageHandler] Service not initialized, returning empty');
|
|
42
|
+
}
|
|
34
43
|
return [];
|
|
35
44
|
}
|
|
36
45
|
|
|
@@ -95,6 +95,13 @@ class SubscriptionManagerImpl {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
async getPackages(): Promise<PurchasesPackage[]> {
|
|
98
|
+
if (__DEV__) {
|
|
99
|
+
console.log('[DEBUG SubscriptionManager] getPackages called', {
|
|
100
|
+
isConfigured: this.isConfigured(),
|
|
101
|
+
isInitialized: this.isInitialized(),
|
|
102
|
+
hasServiceInstance: !!this.serviceInstance,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
98
105
|
this.ensureConfigured();
|
|
99
106
|
if (!this.serviceInstance) {
|
|
100
107
|
this.serviceInstance = getRevenueCatService();
|
|
@@ -57,11 +57,22 @@ function buildSuccessResult(
|
|
|
57
57
|
return { success: true, offering: offerings.current, hasPremium };
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
declare const __DEV__: boolean;
|
|
61
|
+
|
|
60
62
|
export async function initializeSDK(
|
|
61
63
|
deps: InitializerDeps,
|
|
62
64
|
userId: string,
|
|
63
65
|
apiKey?: string
|
|
64
66
|
): Promise<InitializeResult> {
|
|
67
|
+
if (__DEV__) {
|
|
68
|
+
console.log('[DEBUG RevenueCatInitializer] initializeSDK called', {
|
|
69
|
+
userId,
|
|
70
|
+
hasApiKey: !!apiKey,
|
|
71
|
+
isInitialized: deps.isInitialized(),
|
|
72
|
+
currentUserId: deps.getCurrentUserId(),
|
|
73
|
+
isPurchasesConfigured,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
65
76
|
// Case 1: Already initialized with the same user ID
|
|
66
77
|
if (deps.isInitialized() && deps.getCurrentUserId() === userId) {
|
|
67
78
|
try {
|
|
@@ -122,6 +133,9 @@ export async function initializeSDK(
|
|
|
122
133
|
try {
|
|
123
134
|
configureLogHandler();
|
|
124
135
|
|
|
136
|
+
if (__DEV__) {
|
|
137
|
+
console.log('[DEBUG RevenueCatInitializer] Configuring Purchases SDK with userId:', userId);
|
|
138
|
+
}
|
|
125
139
|
await Purchases.configure({
|
|
126
140
|
apiKey: key,
|
|
127
141
|
appUserID: userId,
|
|
@@ -130,11 +144,21 @@ export async function initializeSDK(
|
|
|
130
144
|
deps.setInitialized(true);
|
|
131
145
|
deps.setCurrentUserId(userId);
|
|
132
146
|
|
|
147
|
+
if (__DEV__) {
|
|
148
|
+
console.log('[DEBUG RevenueCatInitializer] Purchases configured, fetching customer info and offerings...');
|
|
149
|
+
}
|
|
133
150
|
const [customerInfo, offerings] = await Promise.all([
|
|
134
151
|
Purchases.getCustomerInfo(),
|
|
135
152
|
Purchases.getOfferings(),
|
|
136
153
|
]);
|
|
137
154
|
|
|
155
|
+
if (__DEV__) {
|
|
156
|
+
console.log('[DEBUG RevenueCatInitializer] Init complete', {
|
|
157
|
+
hasOfferings: !!offerings.current,
|
|
158
|
+
offeringsIdentifier: offerings.current?.identifier,
|
|
159
|
+
packagesCount: offerings.current?.availablePackages?.length ?? 0,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
138
162
|
return buildSuccessResult(deps, customerInfo, offerings);
|
|
139
163
|
} catch (error) {
|
|
140
164
|
getErrorMessage(error, "RevenueCat init failed");
|