@umituz/react-native-subscription 2.27.0 → 2.27.2
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.27.
|
|
3
|
+
"version": "2.27.2",
|
|
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",
|
|
@@ -86,7 +86,28 @@ export function useFeatureGate(params: UseFeatureGateParams): UseFeatureGateResu
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
if (!isAuthenticated) {
|
|
89
|
-
const postAuthAction = () => {
|
|
89
|
+
const postAuthAction = async () => {
|
|
90
|
+
// Wait for free credits to initialize after registration (max 3 seconds)
|
|
91
|
+
const maxWaitTime = 3000;
|
|
92
|
+
const checkInterval = 100;
|
|
93
|
+
let waited = 0;
|
|
94
|
+
|
|
95
|
+
while (waited < maxWaitTime) {
|
|
96
|
+
await new Promise((resolve) => setTimeout(resolve, checkInterval));
|
|
97
|
+
waited += checkInterval;
|
|
98
|
+
|
|
99
|
+
if (creditBalanceRef.current > 0 || hasSubscriptionRef.current) {
|
|
100
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
101
|
+
console.log("[useFeatureGate] Credits/subscription detected after auth", {
|
|
102
|
+
credits: creditBalanceRef.current,
|
|
103
|
+
hasSubscription: hasSubscriptionRef.current,
|
|
104
|
+
waitedMs: waited,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
90
111
|
if (hasSubscriptionRef.current) {
|
|
91
112
|
action();
|
|
92
113
|
return;
|
|
@@ -94,12 +115,23 @@ export function useFeatureGate(params: UseFeatureGateParams): UseFeatureGateResu
|
|
|
94
115
|
|
|
95
116
|
const currentBalance = creditBalanceRef.current;
|
|
96
117
|
if (currentBalance < requiredCredits) {
|
|
118
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
119
|
+
console.log("[useFeatureGate] No credits after waiting, showing paywall", {
|
|
120
|
+
credits: currentBalance,
|
|
121
|
+
waitedMs: waited,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
97
124
|
pendingActionRef.current = action;
|
|
98
125
|
isWaitingForPurchaseRef.current = true;
|
|
99
126
|
onShowPaywallRef.current(requiredCredits);
|
|
100
127
|
return;
|
|
101
128
|
}
|
|
102
129
|
|
|
130
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
131
|
+
console.log("[useFeatureGate] Proceeding with action after auth", {
|
|
132
|
+
credits: currentBalance,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
103
135
|
action();
|
|
104
136
|
};
|
|
105
137
|
onShowAuthModal(postAuthAction);
|