@umituz/react-native-subscription 2.14.99 → 2.14.100
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/README.md +211 -394
- package/package.json +1 -1
- package/src/application/README.md +46 -225
- package/src/application/ports/README.md +42 -97
- package/src/domain/README.md +36 -384
- package/src/domain/constants/README.md +0 -56
- package/src/domain/entities/README.md +43 -169
- package/src/domain/errors/README.md +33 -287
- package/src/domain/value-objects/README.md +43 -179
- package/src/domains/README.md +50 -238
- package/src/domains/README.md.bak +274 -0
- package/src/domains/config/README.md +93 -383
- package/src/domains/config/domain/README.md +23 -376
- package/src/domains/config/domain/entities/README.md +34 -343
- package/src/domains/paywall/README.md +99 -369
- package/src/domains/paywall/components/README.md +34 -178
- package/src/domains/paywall/entities/README.md +34 -193
- package/src/domains/paywall/hooks/README.md +34 -122
- package/src/domains/wallet/README.md +34 -275
- package/src/domains/wallet/README.md.bak +209 -0
- package/src/domains/wallet/domain/README.md +34 -101
- package/src/domains/wallet/domain/entities/README.md +34 -115
- package/src/domains/wallet/domain/errors/README.md +34 -151
- package/src/domains/wallet/infrastructure/README.md +34 -89
- package/src/domains/wallet/presentation/components/README.md +34 -224
- package/src/domains/wallet/presentation/hooks/README.md +34 -248
- package/src/infrastructure/README.md +37 -496
- package/src/infrastructure/mappers/README.md +0 -13
- package/src/infrastructure/repositories/README.md +74 -360
- package/src/infrastructure/services/README.md +95 -370
- package/src/presentation/README.md +123 -408
- package/src/presentation/README.md.bak +172 -0
- package/src/presentation/components/README.md +151 -179
- package/src/presentation/components/README.md.bak +217 -0
- package/src/presentation/components/details/CreditRow.md +65 -310
- package/src/presentation/components/details/DetailRow.md +63 -255
- package/src/presentation/components/details/PremiumDetailsCard.md +65 -238
- package/src/presentation/components/details/PremiumStatusBadge.md +64 -239
- package/src/presentation/components/details/README.md +97 -447
- package/src/presentation/components/feedback/PaywallFeedbackModal.md +63 -287
- package/src/presentation/components/feedback/README.md +97 -445
- package/src/presentation/components/paywall/PaywallModal.md +66 -416
- package/src/presentation/components/paywall/README.md +50 -186
- package/src/presentation/components/sections/README.md +97 -466
- package/src/presentation/components/sections/SubscriptionSection.md +92 -244
- package/src/presentation/hooks/README.md +154 -741
- package/src/presentation/hooks/useAuthAwarePurchase.md +58 -325
- package/src/presentation/hooks/useAuthGate.md +61 -375
- package/src/presentation/hooks/useAuthSubscriptionSync.md +66 -370
- package/src/presentation/hooks/useCreditChecker.md +73 -378
- package/src/presentation/hooks/useCredits.md +74 -313
- package/src/presentation/hooks/useCredits.md.bak +231 -0
- package/src/presentation/hooks/useCreditsGate.md +66 -318
- package/src/presentation/hooks/useDeductCredit.md +0 -76
- package/src/presentation/hooks/useDevTestCallbacks.md +63 -394
- package/src/presentation/hooks/useFeatureGate.md +105 -150
- package/src/presentation/hooks/useFeatureGate.md.bak +284 -0
- package/src/presentation/hooks/useInitializeCredits.md +64 -430
- package/src/presentation/hooks/usePaywall.md +61 -306
- package/src/presentation/hooks/usePaywallOperations.md +64 -458
- package/src/presentation/hooks/usePaywallVisibility.md +67 -316
- package/src/presentation/hooks/usePremium.md +84 -226
- package/src/presentation/hooks/usePremiumGate.md +60 -395
- package/src/presentation/hooks/usePremiumWithCredits.md +64 -401
- package/src/presentation/hooks/useSubscription.md +66 -422
- package/src/presentation/hooks/useSubscriptionDetails.md +65 -410
- package/src/presentation/hooks/useSubscriptionGate.md +80 -164
- package/src/presentation/hooks/useSubscriptionSettingsConfig.md +66 -346
- package/src/presentation/hooks/useSubscriptionStatus.md +66 -396
- package/src/presentation/hooks/useUserTier.md +63 -328
- package/src/presentation/hooks/useUserTierWithRepository.md +64 -424
- package/src/presentation/screens/README.md +48 -190
- package/src/presentation/types/README.md +0 -16
- package/src/presentation/utils/README.md +0 -21
- package/src/revenuecat/README.md +99 -518
- package/src/revenuecat/application/README.md +35 -150
- package/src/revenuecat/application/ports/README.md +34 -162
- package/src/revenuecat/domain/README.md +42 -141
- package/src/revenuecat/domain/constants/README.md +34 -176
- package/src/revenuecat/domain/entities/README.md +34 -374
- package/src/revenuecat/domain/errors/README.md +47 -191
- package/src/revenuecat/domain/types/README.md +34 -366
- package/src/revenuecat/domain/value-objects/README.md +34 -434
- package/src/revenuecat/infrastructure/README.md +34 -43
- package/src/revenuecat/infrastructure/config/README.md +32 -23
- package/src/revenuecat/infrastructure/handlers/README.md +34 -211
- package/src/revenuecat/infrastructure/managers/README.md +34 -42
- package/src/revenuecat/infrastructure/services/README.md +35 -318
- package/src/revenuecat/infrastructure/utils/README.md +34 -375
- package/src/revenuecat/presentation/README.md +34 -176
- package/src/revenuecat/presentation/hooks/README.md +29 -35
- package/src/utils/README.md +38 -525
|
@@ -2,343 +2,94 @@
|
|
|
2
2
|
|
|
3
3
|
Simple global state management for paywall visibility using external store.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Location
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
usePaywallVisibility,
|
|
10
|
-
paywallControl
|
|
11
|
-
} from '@umituz/react-native-subscription';
|
|
12
|
-
```
|
|
7
|
+
**Import Path**: `@umituz/react-native-subscription`
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
**File**: `src/presentation/hooks/usePaywallVisibility.ts`
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
function usePaywallVisibility(): {
|
|
18
|
-
showPaywall: boolean;
|
|
19
|
-
setShowPaywall: (visible: boolean) => void;
|
|
20
|
-
openPaywall: () => void;
|
|
21
|
-
closePaywall: () => void;
|
|
22
|
-
}
|
|
11
|
+
**Type**: Hook
|
|
23
12
|
|
|
24
|
-
|
|
25
|
-
paywallControl: {
|
|
26
|
-
open: () => void;
|
|
27
|
-
close: () => void;
|
|
28
|
-
isOpen: () => boolean;
|
|
29
|
-
}
|
|
30
|
-
```
|
|
13
|
+
## Strategy
|
|
31
14
|
|
|
32
|
-
|
|
15
|
+
### Global Paywall State Management
|
|
33
16
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
1. **External Store**: Use Zustand or similar for global state
|
|
18
|
+
2. **Visibility Control**: Simple boolean for show/hide
|
|
19
|
+
3. **Global Access**: Available from any component
|
|
20
|
+
4. **Direct Control**: Provide paywallControl for non-React contexts
|
|
21
|
+
5. **Single Instance**: One paywall modal at app root
|
|
22
|
+
6. **State Persistence**: Maintain visibility across component unmounts
|
|
40
23
|
|
|
41
|
-
|
|
24
|
+
### Integration Points
|
|
42
25
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
- **App Root**: Paywall modal should be placed at app root
|
|
27
|
+
- **Any Component**: Can trigger paywall from anywhere
|
|
28
|
+
- **Deep Links**: Can open paywall from URLs
|
|
29
|
+
- **Push Notifications**: Can open paywall from notifications
|
|
30
|
+
- **usePremium**: For conditional display based on status
|
|
46
31
|
|
|
47
|
-
|
|
32
|
+
## Restrictions
|
|
48
33
|
|
|
49
|
-
|
|
50
|
-
<Modal visible={showPaywall} onRequestClose={closePaywall}>
|
|
51
|
-
<PaywallContent onClose={closePaywall} />
|
|
52
|
-
</Modal>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
```
|
|
34
|
+
### REQUIRED
|
|
56
35
|
|
|
57
|
-
|
|
36
|
+
- **Single Modal**: MUST place paywall modal once at app root
|
|
37
|
+
- **Close Handler**: MUST provide close button in paywall
|
|
38
|
+
- **Premium Check**: SHOULD hide paywall when user becomes premium
|
|
39
|
+
- **Back Handler**: SHOULD handle Android back button
|
|
58
40
|
|
|
59
|
-
###
|
|
41
|
+
### PROHIBITED
|
|
60
42
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<YourAppNavigation />
|
|
66
|
-
<PaywallModal />
|
|
67
|
-
</>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
43
|
+
- **NEVER** place multiple paywall modals in component tree
|
|
44
|
+
- **NEVER** manage visibility locally (use this hook instead)
|
|
45
|
+
- **DO NOT** show paywall too frequently
|
|
46
|
+
- **DO NOT** trap users without exit option
|
|
70
47
|
|
|
71
|
-
|
|
72
|
-
const { showPaywall, closePaywall } = usePaywallVisibility();
|
|
48
|
+
### CRITICAL SAFETY
|
|
73
49
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
```
|
|
50
|
+
- **ALWAYS** provide close button
|
|
51
|
+
- **NEVER** trap users in paywall
|
|
52
|
+
- **MUST** handle back button on Android
|
|
53
|
+
- **ALWAYS** hide paywall after successful purchase
|
|
81
54
|
|
|
82
|
-
|
|
55
|
+
## AI Agent Guidelines
|
|
83
56
|
|
|
84
|
-
|
|
85
|
-
function PremiumFeature() {
|
|
86
|
-
const { openPaywall } = usePaywallVisibility();
|
|
57
|
+
### When Implementing Paywall Visibility
|
|
87
58
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
```
|
|
59
|
+
1. **Always** place paywall modal once at app root
|
|
60
|
+
2. **Always** provide close button
|
|
61
|
+
3. **Always** use openPaywall/closePaywall functions
|
|
62
|
+
4. **Always** hide paywall after successful purchase
|
|
63
|
+
5. **Never** manage visibility locally in components
|
|
96
64
|
|
|
97
|
-
###
|
|
65
|
+
### Integration Checklist
|
|
98
66
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
67
|
+
- [ ] Import from correct path: `@umituz/react-native-subscription`
|
|
68
|
+
- [ ] Place paywall modal once at app root
|
|
69
|
+
- [ ] Use openPaywall to show paywall
|
|
70
|
+
- [ ] Use closePaywall to hide paywall
|
|
71
|
+
- [ ] Provide close button in paywall
|
|
72
|
+
- [ ] Handle Android back button
|
|
73
|
+
- [ ] Hide paywall when user becomes premium
|
|
74
|
+
- [ ] Test paywall opens from any component
|
|
75
|
+
- [ ] Test paywallControl for non-React contexts
|
|
76
|
+
- [ ] Test deep link integration
|
|
102
77
|
|
|
103
|
-
|
|
104
|
-
if (url.pathname === '/upgrade') {
|
|
105
|
-
paywallControl.open();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
78
|
+
### Common Patterns
|
|
108
79
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
80
|
+
1. **App Root Setup**: Single modal instance at app root
|
|
81
|
+
2. **Trigger Button**: Any component can open paywall
|
|
82
|
+
3. **Direct Control**: Use paywallControl in non-React code
|
|
83
|
+
4. **Conditional Display**: Auto-show based on user status
|
|
84
|
+
5. **History/Navigation**: Handle navigation with paywall
|
|
85
|
+
6. **Timeout/Auto-Close**: Auto-close after timeout
|
|
86
|
+
7. **Deep Links**: Open from URL schemes
|
|
115
87
|
|
|
116
|
-
|
|
88
|
+
## Related Documentation
|
|
117
89
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// Auto-show paywall for free users on certain screens
|
|
125
|
-
if (!isPremium && someCondition) {
|
|
126
|
-
openPaywall();
|
|
127
|
-
}
|
|
128
|
-
}, [isPremium]);
|
|
129
|
-
|
|
130
|
-
if (isPremium) return null; // Don't show for premium users
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<Modal visible={showPaywall}>
|
|
134
|
-
<PaywallContent onClose={closePaywall} />
|
|
135
|
-
</Modal>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### With History/Navigation
|
|
141
|
-
|
|
142
|
-
```typescript
|
|
143
|
-
function PaywallWithHistory() {
|
|
144
|
-
const { showPaywall, closePaywall, openPaywall } = usePaywallVisibility();
|
|
145
|
-
const navigation = useNavigation();
|
|
146
|
-
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
const unsubscribe = navigation.addListener('focus', () => {
|
|
149
|
-
// Show paywall when returning to certain screens
|
|
150
|
-
if (shouldShowPaywall()) {
|
|
151
|
-
openPaywall();
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
return unsubscribe;
|
|
156
|
-
}, [navigation]);
|
|
157
|
-
|
|
158
|
-
const handleClose = () => {
|
|
159
|
-
closePaywall();
|
|
160
|
-
navigation.goBack();
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
return (
|
|
164
|
-
<Modal visible={showPaywall}>
|
|
165
|
-
<PaywallContent onClose={handleClose} />
|
|
166
|
-
</Modal>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## Examples
|
|
172
|
-
|
|
173
|
-
### Global Paywall System
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
// App.tsx
|
|
177
|
-
function App() {
|
|
178
|
-
return (
|
|
179
|
-
<PaywallProvider>
|
|
180
|
-
<Navigation />
|
|
181
|
-
<GlobalPaywall />
|
|
182
|
-
</PaywallProvider>
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// components/GlobalPaywall.tsx
|
|
187
|
-
function GlobalPaywall() {
|
|
188
|
-
const { showPaywall, closePaywall } = usePaywallVisibility();
|
|
189
|
-
|
|
190
|
-
return (
|
|
191
|
-
<Modal visible={showPaywall} animationType="slide">
|
|
192
|
-
<PaywallScreen onClose={closePaywall} />
|
|
193
|
-
</Modal>
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Any component can trigger the paywall
|
|
198
|
-
function UpgradeButton() {
|
|
199
|
-
const { openPaywall } = usePaywallVisibility();
|
|
200
|
-
return <Button onPress={openPaywall} title="Upgrade" />;
|
|
201
|
-
}
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### With Context Integration
|
|
205
|
-
|
|
206
|
-
```typescript
|
|
207
|
-
function PaywallWithContext() {
|
|
208
|
-
const { showPaywall, closePaywall, setShowPaywall } = usePaywallVisibility();
|
|
209
|
-
const { isPremium } = usePremium();
|
|
210
|
-
|
|
211
|
-
// Close paywall when user becomes premium
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
if (isPremium && showPaywall) {
|
|
214
|
-
setShowPaywall(false);
|
|
215
|
-
}
|
|
216
|
-
}, [isPremium, showPaywall]);
|
|
217
|
-
|
|
218
|
-
if (isPremium) return null;
|
|
219
|
-
|
|
220
|
-
return (
|
|
221
|
-
<Modal visible={showPaywall}>
|
|
222
|
-
<PaywallScreen onClose={closePaywall} />
|
|
223
|
-
</Modal>
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
### With Timeout/Auto-Close
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
function TimedPaywall() {
|
|
232
|
-
const { showPaywall, closePaywall } = usePaywallVisibility();
|
|
233
|
-
|
|
234
|
-
useEffect(() => {
|
|
235
|
-
if (!showPaywall) return;
|
|
236
|
-
|
|
237
|
-
// Auto-close after 30 seconds
|
|
238
|
-
const timer = setTimeout(() => {
|
|
239
|
-
closePaywall();
|
|
240
|
-
}, 30000);
|
|
241
|
-
|
|
242
|
-
return () => clearTimeout(timer);
|
|
243
|
-
}, [showPaywall, closePaywall]);
|
|
244
|
-
|
|
245
|
-
return (
|
|
246
|
-
<Modal visible={showPaywall}>
|
|
247
|
-
<PaywallContent onClose={closePaywall} />
|
|
248
|
-
</Modal>
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
### With Back Handler
|
|
254
|
-
|
|
255
|
-
```typescript
|
|
256
|
-
function PaywallWithBackHandler() {
|
|
257
|
-
const { showPaywall, closePaywall } = usePaywallVisibility();
|
|
258
|
-
|
|
259
|
-
useBackHandler(showPaywall, () => {
|
|
260
|
-
closePaywall();
|
|
261
|
-
return true; // Prevent default back behavior
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
return (
|
|
265
|
-
<Modal visible={showPaywall}>
|
|
266
|
-
<PaywallContent onClose={closePaywall} />
|
|
267
|
-
</Modal>
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
### From Deep Link
|
|
273
|
-
|
|
274
|
-
```typescript
|
|
275
|
-
// Deep link handler
|
|
276
|
-
import { paywallControl } from '@umituz/react-native-subscription';
|
|
277
|
-
import { Linking } from 'react-native';
|
|
278
|
-
|
|
279
|
-
Linking.addEventListener('url', ({ url }) => {
|
|
280
|
-
const parsed = new URL(url);
|
|
281
|
-
|
|
282
|
-
if (parsed.pathname === '/upgrade') {
|
|
283
|
-
paywallControl.open();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (parsed.searchParams.get('show_paywall') === 'true') {
|
|
287
|
-
paywallControl.open();
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
### From Push Notification
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
// Push notification handler
|
|
296
|
-
import { paywallControl } from '@umituz/react-native-subscription';
|
|
297
|
-
import messaging from '@react-native-firebase/messaging';
|
|
298
|
-
|
|
299
|
-
messaging().onNotificationOpenedApp((remoteMessage) => {
|
|
300
|
-
if (remoteMessage.data?.type === 'paywall') {
|
|
301
|
-
paywallControl.open();
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
// Or when app is in background
|
|
306
|
-
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
|
|
307
|
-
if (remoteMessage.data?.show_paywall) {
|
|
308
|
-
// Store flag to show paywall when app opens
|
|
309
|
-
AsyncStorage.setItem('pending_paywall', 'true');
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
// Then in your app
|
|
314
|
-
useEffect(() => {
|
|
315
|
-
AsyncStorage.getItem('pending_paywall').then((value) => {
|
|
316
|
-
if (value === 'true') {
|
|
317
|
-
paywallControl.open();
|
|
318
|
-
AsyncStorage.removeItem('pending_paywall');
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}, []);
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
## Best Practices
|
|
325
|
-
|
|
326
|
-
1. **Single modal instance** - Place paywall once at app root
|
|
327
|
-
2. **Global access** - Use `paywallControl` for non-React contexts
|
|
328
|
-
3. **Clean close** - Always provide close button
|
|
329
|
-
4. **Back handler** - Handle Android back button
|
|
330
|
-
5. **State persistence** - Don't rely on component state
|
|
331
|
-
6. **Auto-close for premium** - Hide when user subscribes
|
|
332
|
-
7. **Deeplink support** - Open from URLs and notifications
|
|
333
|
-
|
|
334
|
-
## Related Hooks
|
|
335
|
-
|
|
336
|
-
- **usePaywallOperations** - For paywall purchase operations
|
|
337
|
-
- **usePremium** - For subscription status
|
|
338
|
-
- **usePaywall** - For complete paywall management
|
|
339
|
-
|
|
340
|
-
## See Also
|
|
341
|
-
|
|
342
|
-
- [Paywall Screen](../screens/README.md)
|
|
343
|
-
- [Paywall Components](../components/paywall/README.md)
|
|
344
|
-
- [Modal Integration](../../../docs/MODAL_INTEGRATION.md)
|
|
90
|
+
- **usePaywallOperations**: For paywall purchase operations
|
|
91
|
+
- **usePremium**: For subscription status
|
|
92
|
+
- **usePaywall**: For complete paywall management
|
|
93
|
+
- **Paywall Screen**: `src/presentation/screens/README.md`
|
|
94
|
+
- **Paywall Components**: `src/presentation/components/paywall/README.md`
|
|
95
|
+
- **Modal Integration**: `src/docs/MODAL_INTEGRATION.md`
|