@umituz/react-native-subscription 2.14.99 → 2.14.101
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 +3 -3
- 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/entities/SubscriptionStatus.ts +1 -1
- 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/components/TransactionItem.tsx +1 -1
- 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/ActivationHandler.ts +1 -1
- package/src/infrastructure/services/README.md +95 -370
- package/src/infrastructure/services/SubscriptionService.ts +1 -1
- 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/useDeductCredit.ts +1 -1
- 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/presentation/utils/subscriptionDateUtils.ts +1 -1
- 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,443 +2,93 @@
|
|
|
2
2
|
|
|
3
3
|
Modal paywall component for subscription upgrade.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Location
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import { PaywallModal } from '@umituz/react-native-subscription';
|
|
9
|
-
```
|
|
7
|
+
**Import Path**: `@umituz/react-native-subscription`
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
**File**: `src/presentation/components/paywall/PaywallModal.tsx`
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
interface PaywallModalProps {
|
|
15
|
-
isVisible: boolean;
|
|
16
|
-
onClose: () => void;
|
|
17
|
-
config?: PaywallConfig;
|
|
18
|
-
onPurchase?: (result: PurchaseResult) => void;
|
|
19
|
-
isLoading?: boolean;
|
|
20
|
-
translations?: PaywallTranslations;
|
|
21
|
-
theme?: 'light' | 'dark';
|
|
22
|
-
}
|
|
23
|
-
```
|
|
11
|
+
**Type**: Component
|
|
24
12
|
|
|
25
|
-
##
|
|
13
|
+
## Strategy
|
|
26
14
|
|
|
27
|
-
|
|
28
|
-
function PaywallExample() {
|
|
29
|
-
const [isVisible, setIsVisible] = useState(false);
|
|
15
|
+
### Paywall Display Flow
|
|
30
16
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
1. **Modal Visibility**: Control visibility via isVisible prop
|
|
18
|
+
2. **Configuration**: Display features, pricing, and benefits
|
|
19
|
+
3. **Package Display**: Show available subscription packages
|
|
20
|
+
4. **Purchase Handling**: Handle purchase initiation and completion
|
|
21
|
+
5. **Close Behavior**: Handle modal close/dismissal
|
|
22
|
+
6. **Responsive Design**: Adapt to different screen sizes
|
|
34
23
|
|
|
35
|
-
|
|
36
|
-
isVisible={isVisible}
|
|
37
|
-
onClose={() => setIsVisible(false)}
|
|
38
|
-
/>
|
|
39
|
-
</>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
```
|
|
24
|
+
### Integration Points
|
|
43
25
|
|
|
44
|
-
|
|
26
|
+
- **usePaywallVisibility**: For modal visibility control
|
|
27
|
+
- **useSubscriptionPackages**: For available packages
|
|
28
|
+
- **usePaywallOperations**: For purchase handling
|
|
29
|
+
- **Analytics**: For tracking impressions and conversions
|
|
30
|
+
- **Navigation**: For post-purchase navigation
|
|
45
31
|
|
|
46
|
-
|
|
32
|
+
## Restrictions
|
|
47
33
|
|
|
48
|
-
|
|
49
|
-
<PaywallModal
|
|
50
|
-
isVisible={isVisible}
|
|
51
|
-
onClose={handleClose}
|
|
52
|
-
config={{
|
|
53
|
-
title: 'Unlock Premium',
|
|
54
|
-
description: 'Get unlimited access to all features',
|
|
55
|
-
features: [
|
|
56
|
-
{ icon: '⭐', text: 'Unlimited Access' },
|
|
57
|
-
{ icon: '🚀', text: 'AI-Powered Tools' },
|
|
58
|
-
{ icon: '🛡️', text: 'Ad-Free Experience' },
|
|
59
|
-
],
|
|
60
|
-
}}
|
|
61
|
-
/>
|
|
62
|
-
```
|
|
34
|
+
### REQUIRED
|
|
63
35
|
|
|
64
|
-
|
|
36
|
+
- **Visibility Control**: MUST control via isVisible prop
|
|
37
|
+
- **Close Handler**: MUST provide onClose callback
|
|
38
|
+
- **Purchase Handler**: MUST implement onPurchase callback
|
|
39
|
+
- **Package Display**: MUST show available packages
|
|
65
40
|
|
|
66
|
-
|
|
67
|
-
const paywallConfig: PaywallConfig = {
|
|
68
|
-
title: 'Go Premium',
|
|
69
|
-
description: 'Join thousands of premium users',
|
|
70
|
-
features: [
|
|
71
|
-
{
|
|
72
|
-
icon: '💎',
|
|
73
|
-
text: 'Premium Content',
|
|
74
|
-
description: 'Access exclusive articles and videos',
|
|
75
|
-
highlight: true,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
icon: '⚡',
|
|
79
|
-
text: 'Faster Processing',
|
|
80
|
-
description: 'Get results in seconds, not minutes',
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
icon: '💬',
|
|
84
|
-
text: 'Priority Support',
|
|
85
|
-
description: '24/7 dedicated support team',
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
icon: '🎁',
|
|
89
|
-
text: 'Exclusive Features',
|
|
90
|
-
description: 'Early access to new features',
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
theme: 'dark',
|
|
94
|
-
showCloseButton: true,
|
|
95
|
-
closeOnBackdropPress: false,
|
|
96
|
-
};
|
|
41
|
+
### PROHIBITED
|
|
97
42
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/>
|
|
103
|
-
```
|
|
43
|
+
- **NEVER** trap users without close option
|
|
44
|
+
- **NEVER** show without user trigger or clear reason
|
|
45
|
+
- **DO NOT** show too frequently
|
|
46
|
+
- **DO NOT** hide pricing information
|
|
104
47
|
|
|
105
|
-
|
|
48
|
+
### CRITICAL SAFETY
|
|
106
49
|
|
|
107
|
-
|
|
50
|
+
- **ALWAYS** provide clear close button
|
|
51
|
+
- **NEVER** trap users in modal
|
|
52
|
+
- **MUST** handle all purchase outcomes
|
|
53
|
+
- **ALWAYS** show pricing clearly
|
|
108
54
|
|
|
109
|
-
|
|
110
|
-
<PaywallModal
|
|
111
|
-
isVisible={isVisible}
|
|
112
|
-
onClose={handleClose}
|
|
113
|
-
onPurchase={(result) => {
|
|
114
|
-
if (result.success) {
|
|
115
|
-
Alert.alert('Success', 'Welcome to Premium!');
|
|
116
|
-
setIsVisible(false);
|
|
117
|
-
} else {
|
|
118
|
-
Alert.alert('Error', result.error?.message || 'Purchase failed');
|
|
119
|
-
}
|
|
120
|
-
}}
|
|
121
|
-
/>
|
|
122
|
-
```
|
|
55
|
+
## AI Agent Guidelines
|
|
123
56
|
|
|
124
|
-
###
|
|
57
|
+
### When Implementing Paywall Modals
|
|
125
58
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
59
|
+
1. **Always** provide clear close button
|
|
60
|
+
2. **Always** show pricing transparently
|
|
61
|
+
3. **Always** handle all purchase outcomes
|
|
62
|
+
4. **Always** track impressions and conversions
|
|
63
|
+
5. **Never** trap users without exit
|
|
129
64
|
|
|
130
|
-
|
|
131
|
-
const result = await handlePurchase(pkg);
|
|
65
|
+
### Integration Checklist
|
|
132
66
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
67
|
+
- [ ] Import from correct path: `@umituz/react-native-subscription`
|
|
68
|
+
- [ ] Control visibility via isVisible prop
|
|
69
|
+
- [ ] Implement onClose callback
|
|
70
|
+
- [ ] Implement onPurchase callback
|
|
71
|
+
- [ ] Configure features and benefits
|
|
72
|
+
- [ ] Display package options
|
|
73
|
+
- [ ] Handle loading states
|
|
74
|
+
- [ ] Track analytics events
|
|
75
|
+
- [ ] Test purchase flow
|
|
76
|
+
- [ ] Test close behavior
|
|
77
|
+
- [ ] Verify responsive design
|
|
139
78
|
|
|
140
|
-
|
|
141
|
-
navigation.goBack();
|
|
79
|
+
### Common Patterns
|
|
142
80
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
81
|
+
1. **Manual Trigger**: Show on button press
|
|
82
|
+
2. **Usage Limit**: Show after N free uses
|
|
83
|
+
3. **Feature Gate**: Show when accessing premium feature
|
|
84
|
+
4. **Time-based**: Show after certain time/usage
|
|
85
|
+
5. **Event-driven**: Show on specific app events
|
|
86
|
+
6. **A/B Testing**: Test different copy and layouts
|
|
150
87
|
|
|
151
|
-
|
|
152
|
-
};
|
|
88
|
+
## Related Documentation
|
|
153
89
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
isLoading={isLoading}
|
|
160
|
-
/>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## Customization
|
|
166
|
-
|
|
167
|
-
### Custom Theme
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
const customTheme = {
|
|
171
|
-
colors: {
|
|
172
|
-
primary: '#FF6B6B',
|
|
173
|
-
background: '#1a1a1a',
|
|
174
|
-
card: '#2d2d2d',
|
|
175
|
-
text: '#ffffff',
|
|
176
|
-
textSecondary: '#999999',
|
|
177
|
-
border: '#3d3d3d',
|
|
178
|
-
},
|
|
179
|
-
fonts: {
|
|
180
|
-
title: {
|
|
181
|
-
fontSize: 28,
|
|
182
|
-
fontWeight: 'bold',
|
|
183
|
-
},
|
|
184
|
-
body: {
|
|
185
|
-
fontSize: 16,
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
borderRadius: 16,
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
<PaywallModal
|
|
192
|
-
isVisible={isVisible}
|
|
193
|
-
onClose={handleClose}
|
|
194
|
-
theme={customTheme}
|
|
195
|
-
/>
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### Custom Package Display
|
|
199
|
-
|
|
200
|
-
```typescript
|
|
201
|
-
function CustomPaywall() {
|
|
202
|
-
const { packages } = useSubscriptionPackages();
|
|
203
|
-
|
|
204
|
-
return (
|
|
205
|
-
<PaywallModal
|
|
206
|
-
isVisible={isVisible}
|
|
207
|
-
onClose={handleClose}
|
|
208
|
-
config={{
|
|
209
|
-
title: 'Choose Your Plan',
|
|
210
|
-
packages: packages.map(pkg => ({
|
|
211
|
-
identifier: pkg.identifier,
|
|
212
|
-
title: pkg.product.title,
|
|
213
|
-
description: pkg.product.description,
|
|
214
|
-
price: pkg.product.priceString,
|
|
215
|
-
popular: pkg.identifier.includes('annual'),
|
|
216
|
-
savings: pkg.identifier.includes('annual')
|
|
217
|
-
? 'Save 33%'
|
|
218
|
-
: undefined,
|
|
219
|
-
})),
|
|
220
|
-
}}
|
|
221
|
-
/>
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
## A/B Testing
|
|
227
|
-
|
|
228
|
-
### Variant A
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
const variantAConfig: PaywallConfig = {
|
|
232
|
-
title: 'Unlock Premium',
|
|
233
|
-
description: 'Get unlimited access',
|
|
234
|
-
features: [
|
|
235
|
-
{ icon: '⭐', text: 'Unlimited Access' },
|
|
236
|
-
{ icon: '🚀', text: 'AI Tools' },
|
|
237
|
-
],
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
<PaywallModal
|
|
241
|
-
config={variantAConfig}
|
|
242
|
-
...
|
|
243
|
-
/>
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### Variant B
|
|
247
|
-
|
|
248
|
-
```typescript
|
|
249
|
-
const variantBConfig: PaywallConfig = {
|
|
250
|
-
title: 'Join Premium Members',
|
|
251
|
-
description: 'Over 10,000 users',
|
|
252
|
-
features: [
|
|
253
|
-
{ icon: '💎', text: 'Premium Content' },
|
|
254
|
-
{ icon: '⚡', text: 'Priority Speed' },
|
|
255
|
-
{ icon: '💬', text: 'VIP Support' },
|
|
256
|
-
{ icon: '🎁', text: 'Exclusive Perks' },
|
|
257
|
-
],
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
<PaywallModal
|
|
261
|
-
config={variantBConfig}
|
|
262
|
-
...
|
|
263
|
-
/>
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
## Translations
|
|
267
|
-
|
|
268
|
-
### Multi-Language Support
|
|
269
|
-
|
|
270
|
-
```typescript
|
|
271
|
-
const translations = {
|
|
272
|
-
en: {
|
|
273
|
-
title: 'Unlock Premium',
|
|
274
|
-
subscribe: 'Subscribe Now',
|
|
275
|
-
features: 'Features',
|
|
276
|
-
restore: 'Restore Purchase',
|
|
277
|
-
close: 'Close',
|
|
278
|
-
},
|
|
279
|
-
tr: {
|
|
280
|
-
title: 'Premium\'e Geç',
|
|
281
|
-
subscribe: 'Şimdi Abone Ol',
|
|
282
|
-
features: 'Özellikler',
|
|
283
|
-
restore: 'Satın Almayı Geri Yükle',
|
|
284
|
-
close: 'Kapat',
|
|
285
|
-
},
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
<PaywallModal
|
|
289
|
-
translations={translations[userLanguage]}
|
|
290
|
-
...
|
|
291
|
-
/>
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
## Responsive Design
|
|
295
|
-
|
|
296
|
-
The modal is responsive and adapts to:
|
|
297
|
-
|
|
298
|
-
- **iPhone SE**: Compact layout
|
|
299
|
-
- **iPhone 14 Pro**: Standard layout
|
|
300
|
-
- **iPad**: Tablet-optimized layout
|
|
301
|
-
- **Landscape**: Adjusted spacing
|
|
302
|
-
|
|
303
|
-
## Performance
|
|
304
|
-
|
|
305
|
-
### Lazy Loading
|
|
306
|
-
|
|
307
|
-
```typescript
|
|
308
|
-
function LazyPaywall() {
|
|
309
|
-
const [showPaywall, setShowPaywall] = useState(false);
|
|
310
|
-
|
|
311
|
-
return (
|
|
312
|
-
<>
|
|
313
|
-
<Button onPress={() => setShowPaywall(true)} />
|
|
314
|
-
|
|
315
|
-
{showPaywall && (
|
|
316
|
-
<PaywallModal
|
|
317
|
-
isVisible={showPaywall}
|
|
318
|
-
onClose={() => setShowPaywall(false)}
|
|
319
|
-
/>
|
|
320
|
-
)}
|
|
321
|
-
</>
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
### Preloading Packages
|
|
327
|
-
|
|
328
|
-
```typescript
|
|
329
|
-
function PreloadedPaywall() {
|
|
330
|
-
const { packages, isLoading } = useSubscriptionPackages({
|
|
331
|
-
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
// Preload packages before showing paywall
|
|
335
|
-
useEffect(() => {
|
|
336
|
-
if (!packages.length) {
|
|
337
|
-
// Trigger background fetch
|
|
338
|
-
refetch();
|
|
339
|
-
}
|
|
340
|
-
}, []);
|
|
341
|
-
|
|
342
|
-
return (
|
|
343
|
-
<PaywallModal
|
|
344
|
-
isVisible={isVisible}
|
|
345
|
-
config={{ packages }}
|
|
346
|
-
/>
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
## Best Practices
|
|
352
|
-
|
|
353
|
-
1. **Track impressions** - Log when paywall is shown
|
|
354
|
-
2. **Track dismissals** - Log when and why users close
|
|
355
|
-
3. **Test different copy** - A/B test titles and features
|
|
356
|
-
4. **Use social proof** - Show user count or ratings
|
|
357
|
-
5. **Highlight savings** - Show annual savings
|
|
358
|
-
6. **Make it actionable** - Clear CTA buttons
|
|
359
|
-
7. **Handle orientation** - Test in landscape and portrait
|
|
360
|
-
|
|
361
|
-
## Complete Example
|
|
362
|
-
|
|
363
|
-
```typescript
|
|
364
|
-
function CompletePaywallFlow() {
|
|
365
|
-
const { isPremium } = usePremium();
|
|
366
|
-
const [isVisible, setIsVisible] = useState(false);
|
|
367
|
-
const [paywallShown, setPaywallShown] = useState(false);
|
|
368
|
-
|
|
369
|
-
// Auto-show after 3 actions
|
|
370
|
-
const { actionCount } = useActionCounter();
|
|
371
|
-
useEffect(() => {
|
|
372
|
-
if (!isPremium && actionCount >= 3 && !paywallShown) {
|
|
373
|
-
setIsVisible(true);
|
|
374
|
-
setPaywallShown(true);
|
|
375
|
-
|
|
376
|
-
analytics.track('auto_paywall_shown', {
|
|
377
|
-
trigger: 'action_limit',
|
|
378
|
-
actions: actionCount,
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
}, [actionCount, isPremium, paywallShown]);
|
|
382
|
-
|
|
383
|
-
const handlePurchase = async (result: PurchaseResult) => {
|
|
384
|
-
if (result.success) {
|
|
385
|
-
analytics.track('purchase_completed', {
|
|
386
|
-
packageId: result.packageId,
|
|
387
|
-
revenue: result.revenue,
|
|
388
|
-
trigger: 'auto_paywall',
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
setIsVisible(false);
|
|
392
|
-
|
|
393
|
-
Alert.alert(
|
|
394
|
-
'Welcome to Premium!',
|
|
395
|
-
'Thank you for subscribing.'
|
|
396
|
-
);
|
|
397
|
-
} else {
|
|
398
|
-
analytics.track('purchase_failed', {
|
|
399
|
-
error: result.error?.message,
|
|
400
|
-
trigger: 'auto_paywall',
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
const handleClose = () => {
|
|
406
|
-
const duration = Date.now() - paywallShownAt;
|
|
407
|
-
analytics.track('paywall_closed', {
|
|
408
|
-
duration,
|
|
409
|
-
trigger: 'auto_paywall',
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
setIsVisible(false);
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
return (
|
|
416
|
-
<PaywallModal
|
|
417
|
-
isVisible={isVisible}
|
|
418
|
-
onClose={handleClose}
|
|
419
|
-
onPurchase={handlePurchase}
|
|
420
|
-
config={{
|
|
421
|
-
title: 'You\'re Awesome! 🎉',
|
|
422
|
-
description: `${actionCount} actions completed. Upgrade for unlimited access!`,
|
|
423
|
-
features: [
|
|
424
|
-
{ icon: '∞', text: 'Unlimited Actions', highlight: true },
|
|
425
|
-
{ icon: '⚡', text: 'Lightning Fast' },
|
|
426
|
-
{ icon: '🛡️', text: 'Ad-Free Experience' },
|
|
427
|
-
],
|
|
428
|
-
}}
|
|
429
|
-
/>
|
|
430
|
-
);
|
|
431
|
-
}
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
## Related Components
|
|
435
|
-
|
|
436
|
-
- **PaywallScreen** - Full-screen paywall
|
|
437
|
-
- **PremiumDetailsCard** - Premium status card
|
|
438
|
-
- **PaywallFeedbackModal** - Feedback collection
|
|
439
|
-
|
|
440
|
-
## See Also
|
|
441
|
-
|
|
442
|
-
- [Paywall Domain](../../../domains/paywall/README.md)
|
|
443
|
-
- [usePaywall Hooks](../../hooks/usePaywall.md)
|
|
444
|
-
- [Paywall README](../feedback/README.md)
|
|
90
|
+
- **usePaywall**: Paywall state management
|
|
91
|
+
- **usePaywallOperations**: Purchase operations
|
|
92
|
+
- **usePaywallVisibility**: Visibility control
|
|
93
|
+
- **PaywallDomain**: `../../../domains/paywall/README.md`
|
|
94
|
+
- **Paywall README**: `./README.md`
|