@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 +5 -5
- package/src/domains/credits/presentation/deduct-credit/useDeductCredit.ts +1 -1
- package/src/domains/paywall/components/PaywallModal.tsx +2 -2
- package/src/domains/subscription/application/SubscriptionAuthListener.ts +6 -5
- package/src/domains/subscription/application/initializer/BackgroundInitializer.ts +4 -4
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.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": ">=
|
|
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.
|
|
70
|
-
"@umituz/react-native-design-system": "
|
|
71
|
-
"@umituz/react-native-firebase": "^2.4.
|
|
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",
|
|
@@ -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 (
|
|
40
|
-
|
|
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
|
-
|
|
15
|
-
|
|
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
|
|
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
|
-
//
|
|
109
|
-
//
|
|
110
|
-
//
|
|
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]
|
|
115
|
+
console.log('[BackgroundInitializer] No user available yet, waiting for auth state');
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
const unsubscribe = setupAuthStateListener(() => auth, debouncedInitialize);
|