@umituz/react-native-subscription 2.37.31 → 2.37.32
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/domains/subscription/application/SubscriptionAuthListener.ts +3 -4
- package/src/domains/subscription/application/SubscriptionInitializerTypes.ts +1 -0
- package/src/domains/subscription/application/initializer/ServiceConfigurator.ts +2 -1
- package/src/domains/subscription/infrastructure/hooks/usePurchasePackage.ts +0 -6
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.32",
|
|
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",
|
|
@@ -17,9 +17,8 @@ export const getCurrentUserId = (getAuth: () => FirebaseAuthLike | null): string
|
|
|
17
17
|
|
|
18
18
|
if (user.isAnonymous) {
|
|
19
19
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
20
|
-
console.log(
|
|
20
|
+
console.log(`[SubscriptionAuthListener] Anonymous user - using Firebase anonymous UID: ${user.uid}`);
|
|
21
21
|
}
|
|
22
|
-
return undefined;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
return user.uid;
|
|
@@ -40,13 +39,13 @@ export const setupAuthStateListener = (
|
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
return auth.onAuthStateChanged((user) => {
|
|
43
|
-
const userId =
|
|
42
|
+
const userId = user ? user.uid : undefined;
|
|
44
43
|
|
|
45
44
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
46
45
|
console.log('[SubscriptionAuthListener] 🔔 Auth state changed:', {
|
|
47
46
|
hasUser: !!user,
|
|
48
47
|
isAnonymous: user?.isAnonymous,
|
|
49
|
-
userId: userId || '(undefined -
|
|
48
|
+
userId: userId || '(undefined - no user)',
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
|
|
@@ -7,7 +7,7 @@ import type { CustomerInfo } from "react-native-purchases";
|
|
|
7
7
|
import type { PackageType } from "../../../revenuecat/core/types/RevenueCatTypes";
|
|
8
8
|
|
|
9
9
|
export function configureServices(config: SubscriptionInitConfig, apiKey: string): SubscriptionSyncService {
|
|
10
|
-
const { entitlementId, credits, creditPackages, getFirebaseAuth, showAuthModal, onCreditsUpdated, getAnonymousUserId } = config;
|
|
10
|
+
const { entitlementId, credits, creditPackages, getFirebaseAuth, showAuthModal, onCreditsUpdated, getAnonymousUserId, allowAnonymousPurchases } = config;
|
|
11
11
|
|
|
12
12
|
if (!creditPackages) {
|
|
13
13
|
throw new Error('[ServiceConfigurator] creditPackages configuration is required');
|
|
@@ -59,6 +59,7 @@ export function configureServices(config: SubscriptionInitConfig, apiKey: string
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
const u = auth.currentUser;
|
|
62
|
+
if (allowAnonymousPurchases && u?.isAnonymous) return true;
|
|
62
63
|
return !!(u && !u.isAnonymous);
|
|
63
64
|
},
|
|
64
65
|
showAuthModal,
|
|
@@ -11,7 +11,6 @@ import { useAlert } from "@umituz/react-native-design-system";
|
|
|
11
11
|
import {
|
|
12
12
|
useAuthStore,
|
|
13
13
|
selectUserId,
|
|
14
|
-
selectIsAnonymous,
|
|
15
14
|
} from "@umituz/react-native-auth";
|
|
16
15
|
import { SubscriptionManager } from "../../infrastructure/managers/SubscriptionManager";
|
|
17
16
|
import { SUBSCRIPTION_QUERY_KEYS } from "./subscriptionQueryKeys";
|
|
@@ -32,7 +31,6 @@ interface PurchaseMutationResult {
|
|
|
32
31
|
*/
|
|
33
32
|
export const usePurchasePackage = () => {
|
|
34
33
|
const userId = useAuthStore(selectUserId);
|
|
35
|
-
const isAnonymous = useAuthStore(selectIsAnonymous);
|
|
36
34
|
const queryClient = useQueryClient();
|
|
37
35
|
const { showSuccess, showError } = useAlert();
|
|
38
36
|
|
|
@@ -42,10 +40,6 @@ export const usePurchasePackage = () => {
|
|
|
42
40
|
throw new Error("User not authenticated");
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
if (isAnonymous) {
|
|
46
|
-
throw new Error("Anonymous users cannot purchase subscriptions");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
43
|
const productId = pkg.product.identifier;
|
|
50
44
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
51
45
|
console.log("[Purchase] Calling SubscriptionManager.purchasePackage()");
|