@umituz/react-native-subscription 2.11.25 â 2.11.27
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/presentation/components/feedback/PaywallFeedbackModal.tsx +1 -2
- package/src/presentation/components/paywall/SubscriptionFooter.tsx +0 -1
- package/src/revenuecat/domain/value-objects/RevenueCatConfig.ts +3 -6
- package/src/revenuecat/infrastructure/services/CustomerInfoListenerManager.ts +67 -1
- package/src/revenuecat/infrastructure/utils/ApiKeyResolver.ts +3 -9
- package/src/utils/premiumUtils.ts +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.27",
|
|
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",
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
TouchableWithoutFeedback,
|
|
12
12
|
TextInput,
|
|
13
13
|
KeyboardAvoidingView,
|
|
14
|
-
Platform,
|
|
15
14
|
} from "react-native";
|
|
16
15
|
import { AtomicText } from "@umituz/react-native-design-system";
|
|
17
16
|
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
@@ -79,7 +78,7 @@ export const PaywallFeedbackModal: React.FC<PaywallFeedbackModalProps> = React.m
|
|
|
79
78
|
<TouchableWithoutFeedback onPress={handleSkip}>
|
|
80
79
|
<View style={styles.overlay}>
|
|
81
80
|
<KeyboardAvoidingView
|
|
82
|
-
behavior=
|
|
81
|
+
behavior="padding"
|
|
83
82
|
style={styles.keyboardView}
|
|
84
83
|
>
|
|
85
84
|
<TouchableWithoutFeedback>
|
|
@@ -6,10 +6,8 @@
|
|
|
6
6
|
import type { CustomerInfo } from "react-native-purchases";
|
|
7
7
|
|
|
8
8
|
export interface RevenueCatConfig {
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
/** Android API key */
|
|
12
|
-
androidApiKey?: string;
|
|
9
|
+
/** Primary API key - resolved by main app based on platform */
|
|
10
|
+
apiKey?: string;
|
|
13
11
|
/** Test Store key for development/Expo Go testing */
|
|
14
12
|
testStoreKey?: string;
|
|
15
13
|
/** Entitlement identifier to check for premium status (REQUIRED - app specific) */
|
|
@@ -44,7 +42,6 @@ export interface RevenueCatConfig {
|
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
export interface RevenueCatConfigRequired {
|
|
47
|
-
|
|
48
|
-
androidApiKey: string;
|
|
45
|
+
apiKey: string;
|
|
49
46
|
}
|
|
50
47
|
|
|
@@ -31,16 +31,44 @@ export class CustomerInfoListenerManager {
|
|
|
31
31
|
setupListener(config: RevenueCatConfig): void {
|
|
32
32
|
this.removeListener();
|
|
33
33
|
|
|
34
|
+
if (__DEV__) {
|
|
35
|
+
console.log("[CustomerInfoListener] Setting up listener", {
|
|
36
|
+
userId: this.currentUserId,
|
|
37
|
+
entitlementId: this.entitlementIdentifier,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
addPackageBreadcrumb("subscription", "Setting up customer info listener", {
|
|
35
42
|
userId: this.currentUserId,
|
|
36
43
|
});
|
|
37
44
|
|
|
38
45
|
this.listener = async (customerInfo: CustomerInfo) => {
|
|
39
|
-
if (
|
|
46
|
+
if (__DEV__) {
|
|
47
|
+
console.log("[CustomerInfoListener] đ Listener fired!", {
|
|
48
|
+
userId: this.currentUserId,
|
|
49
|
+
hasActiveEntitlements: Object.keys(customerInfo.entitlements.active).length > 0,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!this.currentUserId) {
|
|
54
|
+
if (__DEV__) {
|
|
55
|
+
console.warn("[CustomerInfoListener] â No userId, skipping");
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
40
59
|
|
|
41
60
|
const hasPremium =
|
|
42
61
|
!!customerInfo.entitlements.active[this.entitlementIdentifier];
|
|
43
62
|
|
|
63
|
+
if (__DEV__) {
|
|
64
|
+
console.log("[CustomerInfoListener] Customer info updated", {
|
|
65
|
+
userId: this.currentUserId,
|
|
66
|
+
hasPremium,
|
|
67
|
+
entitlementIdentifier: this.entitlementIdentifier,
|
|
68
|
+
activeEntitlements: Object.keys(customerInfo.entitlements.active),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
44
72
|
addPackageBreadcrumb("subscription", "Customer info updated", {
|
|
45
73
|
userId: this.currentUserId,
|
|
46
74
|
hasPremium,
|
|
@@ -56,6 +84,15 @@ export class CustomerInfoListenerManager {
|
|
|
56
84
|
const productId = premiumEntitlement.productIdentifier;
|
|
57
85
|
const renewalId = `renewal_${productId}_${premiumEntitlement.expirationDate}`;
|
|
58
86
|
|
|
87
|
+
if (__DEV__) {
|
|
88
|
+
console.log("[CustomerInfoListener] đ° Processing credit renewal", {
|
|
89
|
+
userId: this.currentUserId,
|
|
90
|
+
productId,
|
|
91
|
+
renewalId,
|
|
92
|
+
expirationDate: premiumEntitlement.expirationDate,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
59
96
|
addPackageBreadcrumb(
|
|
60
97
|
"subscription",
|
|
61
98
|
"Processing credit renewal",
|
|
@@ -73,6 +110,13 @@ export class CustomerInfoListenerManager {
|
|
|
73
110
|
renewalId
|
|
74
111
|
);
|
|
75
112
|
|
|
113
|
+
if (__DEV__) {
|
|
114
|
+
console.log("[CustomerInfoListener] â
Credit renewal completed", {
|
|
115
|
+
userId: this.currentUserId,
|
|
116
|
+
productId,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
76
120
|
addPackageBreadcrumb(
|
|
77
121
|
"subscription",
|
|
78
122
|
"Credit renewal completed",
|
|
@@ -82,6 +126,14 @@ export class CustomerInfoListenerManager {
|
|
|
82
126
|
}
|
|
83
127
|
);
|
|
84
128
|
} catch (error) {
|
|
129
|
+
if (__DEV__) {
|
|
130
|
+
console.error("[CustomerInfoListener] â Credit renewal failed", {
|
|
131
|
+
userId: this.currentUserId,
|
|
132
|
+
productId,
|
|
133
|
+
error: error instanceof Error ? error.message : String(error),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
85
137
|
addPackageBreadcrumb(
|
|
86
138
|
"subscription",
|
|
87
139
|
"Credit renewal failed",
|
|
@@ -92,6 +144,20 @@ export class CustomerInfoListenerManager {
|
|
|
92
144
|
}
|
|
93
145
|
);
|
|
94
146
|
}
|
|
147
|
+
} else {
|
|
148
|
+
if (__DEV__) {
|
|
149
|
+
console.warn("[CustomerInfoListener] â ī¸ Premium but no entitlement/expiration", {
|
|
150
|
+
hasPremiumEntitlement: !!premiumEntitlement,
|
|
151
|
+
hasExpirationDate: !!(premiumEntitlement?.expirationDate),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
if (__DEV__) {
|
|
157
|
+
console.log("[CustomerInfoListener] âšī¸ Skipping credit renewal", {
|
|
158
|
+
hasPremium,
|
|
159
|
+
hasCallback: !!config.onCreditRenewal,
|
|
160
|
+
});
|
|
95
161
|
}
|
|
96
162
|
}
|
|
97
163
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* API Key Resolver
|
|
3
3
|
* Resolves RevenueCat API key from configuration
|
|
4
|
+
* NOTE: Main app is responsible for resolving platform-specific keys
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
import { Platform } from "react-native";
|
|
7
7
|
import type { RevenueCatConfig } from "../../domain/value-objects/RevenueCatConfig";
|
|
8
8
|
import { isExpoGo, isProductionBuild } from "./ExpoGoDetector";
|
|
9
9
|
|
|
@@ -14,23 +14,21 @@ import { isExpoGo, isProductionBuild } from "./ExpoGoDetector";
|
|
|
14
14
|
export function shouldUseTestStore(config: RevenueCatConfig): boolean {
|
|
15
15
|
const testKey = config.testStoreKey;
|
|
16
16
|
|
|
17
|
-
// No test key configured - always use production keys
|
|
18
17
|
if (!testKey) {
|
|
19
18
|
return false;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
// CRITICAL: Production builds should NEVER use test store
|
|
23
21
|
if (isProductionBuild() && !isExpoGo()) {
|
|
24
22
|
return false;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
// Only use test store in Expo Go
|
|
28
25
|
return isExpoGo();
|
|
29
26
|
}
|
|
30
27
|
|
|
31
28
|
/**
|
|
32
29
|
* Get RevenueCat API key from config
|
|
33
30
|
* Returns Test Store key if in Expo Go environment ONLY
|
|
31
|
+
* Main app must provide resolved platform-specific apiKey in config
|
|
34
32
|
*/
|
|
35
33
|
export function resolveApiKey(config: RevenueCatConfig): string | null {
|
|
36
34
|
const useTestStore = shouldUseTestStore(config);
|
|
@@ -39,11 +37,7 @@ export function resolveApiKey(config: RevenueCatConfig): string | null {
|
|
|
39
37
|
return config.testStoreKey ?? null;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
const key =
|
|
43
|
-
? config.iosApiKey
|
|
44
|
-
: Platform.OS === 'android'
|
|
45
|
-
? config.androidApiKey
|
|
46
|
-
: config.iosApiKey;
|
|
40
|
+
const key = config.apiKey;
|
|
47
41
|
|
|
48
42
|
if (!key || key === "" || key.includes("YOUR_")) {
|
|
49
43
|
return null;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Premium Utilities
|
|
3
|
-
*
|
|
4
|
-
* Re-export of premium status utilities for backward compatibility
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// Re-export for backward compatibility
|
|
8
|
-
export { getIsPremium } from './premiumStatusUtils';
|
|
9
|
-
export { getUserTierInfoAsync, checkPremiumAccessAsync } from './premiumAsyncUtils';
|