@umituz/react-native-subscription 2.37.90 → 2.37.92
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/initializer/BackgroundInitializer.ts +9 -0
- package/src/domains/subscription/infrastructure/handlers/package-operations/PackagePurchaser.ts +8 -0
- package/src/domains/subscription/infrastructure/managers/SubscriptionManager.ts +8 -0
- package/src/domains/subscription/infrastructure/services/purchase/PurchaseExecutor.ts +2 -2
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.92",
|
|
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",
|
|
@@ -74,6 +74,15 @@ export async function startBackgroundInitialization(config: SubscriptionInitConf
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
debounceTimer = setTimeout(async () => {
|
|
77
|
+
// Don't initialize when there's no user and no previous user.
|
|
78
|
+
// This is the initial signed-out state before auth resolves, not a logout.
|
|
79
|
+
if (!revenueCatUserId && !lastUserId) {
|
|
80
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
81
|
+
console.log('[BackgroundInitializer] No user and no previous user, waiting for auth');
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
77
86
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
78
87
|
console.log('[BackgroundInitializer] Auth state listener triggered, reinitializing with userId:', revenueCatUserId || '(undefined - anonymous)');
|
|
79
88
|
}
|
package/src/domains/subscription/infrastructure/handlers/package-operations/PackagePurchaser.ts
CHANGED
|
@@ -6,6 +6,14 @@ export async function executePurchase(
|
|
|
6
6
|
pkg: PurchasesPackage,
|
|
7
7
|
userId: string
|
|
8
8
|
): Promise<boolean> {
|
|
9
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
10
|
+
console.log("[PackagePurchaser] executePurchase called", {
|
|
11
|
+
productId: pkg.product.identifier,
|
|
12
|
+
userId,
|
|
13
|
+
serviceInitialized: service.isInitialized(),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
if (!service.isInitialized()) {
|
|
10
18
|
throw new Error("Service not initialized");
|
|
11
19
|
}
|
|
@@ -101,6 +101,14 @@ class SubscriptionManagerImpl {
|
|
|
101
101
|
if (explicitUserId) {
|
|
102
102
|
await this.initialize(explicitUserId);
|
|
103
103
|
}
|
|
104
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
105
|
+
console.log('[SubscriptionManager] purchasePackage: init complete, starting purchase', {
|
|
106
|
+
productId: pkg.product.identifier,
|
|
107
|
+
hasPackageHandler: !!this.packageHandler,
|
|
108
|
+
hasService: !!this.serviceInstance,
|
|
109
|
+
serviceInitialized: this.serviceInstance?.isInitialized() ?? false,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
104
112
|
this.ensurePackageHandlerInitialized();
|
|
105
113
|
const resolvedUserId = explicitUserId || getCurrentUserIdOrThrow(this.state);
|
|
106
114
|
const result = await purchasePackageOperation(pkg, this.managerConfig, resolvedUserId, this.packageHandler!);
|
|
@@ -86,8 +86,8 @@ async function executeSubscriptionPurchase(
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
/** Default timeout for purchase operations (
|
|
90
|
-
const PURCHASE_TIMEOUT_MS =
|
|
89
|
+
/** Default timeout for purchase operations (60 seconds) */
|
|
90
|
+
const PURCHASE_TIMEOUT_MS = 60_000;
|
|
91
91
|
|
|
92
92
|
function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T> {
|
|
93
93
|
return new Promise<T>((resolve, reject) => {
|