@umituz/react-native-subscription 2.37.77 → 2.37.79

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.37.77",
3
+ "version": "2.37.79",
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",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@tanstack/react-query": ">=5.0.0",
42
- "@umituz/react-native-auth": ">=3.0.0",
42
+ "@umituz/react-native-auth": ">=4.0.0",
43
43
  "expo": ">=54.0.0",
44
44
  "expo-constants": ">=17.0.0",
45
45
  "expo-image": ">=3.0.0",
@@ -66,9 +66,9 @@
66
66
  "@types/react-native": "^0.72.8",
67
67
  "@typescript-eslint/eslint-plugin": "^8.50.1",
68
68
  "@typescript-eslint/parser": "^8.50.1",
69
- "@umituz/react-native-auth": "^3.8.3",
70
- "@umituz/react-native-design-system": "latest",
71
- "@umituz/react-native-firebase": "^2.4.0",
69
+ "@umituz/react-native-auth": "^4.3.45",
70
+ "@umituz/react-native-design-system": "^4.25.50",
71
+ "@umituz/react-native-firebase": "^2.4.61",
72
72
  "eslint": "^9.39.2",
73
73
  "eslint-plugin-react": "^7.37.5",
74
74
  "eslint-plugin-react-hooks": "^7.0.1",
@@ -64,7 +64,7 @@ export const useDeductCredit = ({
64
64
  console.error('[useDeductCredit] Unexpected error during credit refund', {
65
65
  amount,
66
66
  userId,
67
- error
67
+ error: error instanceof Error ? error.message : String(error),
68
68
  });
69
69
  return false;
70
70
  }
@@ -36,8 +36,8 @@ export const PaywallModal: React.FC<PaywallModalProps> = React.memo((props) => {
36
36
  if (!url) return;
37
37
  try {
38
38
  if (await Linking.canOpenURL(url)) await Linking.openURL(url);
39
- } catch (_err) {
40
- // Silently fail - legal links are non-critical
39
+ } catch (error) {
40
+ console.error('[PaywallModal] Failed to open URL:', error instanceof Error ? error.message : String(error));
41
41
  }
42
42
  }, []);
43
43
 
@@ -11,10 +11,9 @@ export const getCurrentUserId = (getAuth: () => FirebaseAuthLike | null): string
11
11
  return undefined;
12
12
  }
13
13
 
14
- if (user.isAnonymous) {
15
- return undefined;
16
- }
17
-
14
+ // Return UID for ALL users including anonymous.
15
+ // Anonymous users need RevenueCat initialized so they can purchase subscriptions.
16
+ // Their credits are stored at users/{anonymousUID}/credits/balance.
18
17
  return user.uid;
19
18
  };
20
19
 
@@ -28,11 +27,13 @@ export const setupAuthStateListener = (
28
27
  }
29
28
 
30
29
  return auth.onAuthStateChanged((user) => {
31
- if (!user || user.isAnonymous) {
30
+ if (!user) {
32
31
  onUserChange(undefined);
33
32
  return;
34
33
  }
35
34
 
35
+ // Pass UID for ALL users including anonymous.
36
+ // Anonymous users need RevenueCat initialized for purchases.
36
37
  onUserChange(user.uid);
37
38
  });
38
39
  };
@@ -105,14 +105,14 @@ export async function startBackgroundInitialization(config: SubscriptionInitConf
105
105
  console.log('[BackgroundInitializer] Initial RevenueCat userId:', initialRevenueCatUserId || '(undefined - anonymous)');
106
106
  }
107
107
 
108
- // Only initialize immediately if we have a real (non-anonymous) user ID.
109
- // If anonymous, skip and wait for auth listener to provide the real user ID.
110
- // This prevents a Firestore permission-denied error from querying with an anonymous ID.
108
+ // Initialize RevenueCat for all users (including anonymous).
109
+ // Anonymous users get their Firebase UID passed to RevenueCat so they can make purchases.
110
+ // Credits are stored at users/{uid}/credits/balance regardless of auth status.
111
111
  if (initialRevenueCatUserId) {
112
112
  await initializeInBackground(initialRevenueCatUserId);
113
113
  lastInitSucceeded = true;
114
114
  } else if (typeof __DEV__ !== 'undefined' && __DEV__) {
115
- console.log('[BackgroundInitializer] Skipping anonymous init, waiting for auth state');
115
+ console.log('[BackgroundInitializer] No user available yet, waiting for auth state');
116
116
  }
117
117
 
118
118
  const unsubscribe = setupAuthStateListener(() => auth, debouncedInitialize);