@umituz/react-native-subscription 2.19.5 → 2.19.6
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.19.
|
|
3
|
+
"version": "2.19.6",
|
|
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",
|
|
@@ -14,11 +14,17 @@ export class CustomerInfoListenerManager {
|
|
|
14
14
|
private listener: CustomerInfoUpdateListener | null = null;
|
|
15
15
|
private currentUserId: string | null = null;
|
|
16
16
|
private entitlementIdentifier: string;
|
|
17
|
+
private lastPurchaseTime: number = 0;
|
|
18
|
+
private static readonly PURCHASE_DEBOUNCE_MS = 5000;
|
|
17
19
|
|
|
18
20
|
constructor(entitlementIdentifier: string) {
|
|
19
21
|
this.entitlementIdentifier = entitlementIdentifier;
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
notifyPurchaseCompleted(): void {
|
|
25
|
+
this.lastPurchaseTime = Date.now();
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
setUserId(userId: string): void {
|
|
23
29
|
this.currentUserId = userId;
|
|
24
30
|
}
|
|
@@ -39,6 +45,13 @@ export class CustomerInfoListenerManager {
|
|
|
39
45
|
!!customerInfo.entitlements.active[this.entitlementIdentifier];
|
|
40
46
|
|
|
41
47
|
if (hasPremium && config.onCreditRenewal) {
|
|
48
|
+
const timeSincePurchase = Date.now() - this.lastPurchaseTime;
|
|
49
|
+
const isRecentPurchase = timeSincePurchase < CustomerInfoListenerManager.PURCHASE_DEBOUNCE_MS;
|
|
50
|
+
|
|
51
|
+
if (isRecentPurchase) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
const premiumEntitlement =
|
|
43
56
|
customerInfo.entitlements.active[this.entitlementIdentifier];
|
|
44
57
|
|
|
@@ -89,7 +89,11 @@ export class RevenueCatService implements IRevenueCatService {
|
|
|
89
89
|
pkg: PurchasesPackage,
|
|
90
90
|
userId: string
|
|
91
91
|
): Promise<PurchaseResult> {
|
|
92
|
-
|
|
92
|
+
const result = await handlePurchase(this.getSDKParams(), pkg, userId);
|
|
93
|
+
if (result.success) {
|
|
94
|
+
this.listenerManager.notifyPurchaseCompleted();
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
async restorePurchases(userId: string): Promise<RestoreResult> {
|