@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,229 +2,87 @@
|
|
|
2
2
|
|
|
3
3
|
Hook for checking and managing premium subscription status.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
<View>
|
|
90
|
-
<Text>Status: {isPremium ? 'Premium' : 'Free'}</Text>
|
|
91
|
-
|
|
92
|
-
<Button
|
|
93
|
-
onPress={handleRefresh}
|
|
94
|
-
disabled={isLoading}
|
|
95
|
-
title="Refresh Status"
|
|
96
|
-
/>
|
|
97
|
-
</View>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### With Full Subscription Details
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
function SubscriptionInfo() {
|
|
106
|
-
const { isPremium, subscription } = usePremium();
|
|
107
|
-
|
|
108
|
-
if (!subscription) return null;
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<View>
|
|
112
|
-
<Text>Type: {subscription.type}</Text>
|
|
113
|
-
<Text>Active: {subscription.isActive ? 'Yes' : 'No'}</Text>
|
|
114
|
-
|
|
115
|
-
{subscription.expirationDate && (
|
|
116
|
-
<Text>
|
|
117
|
-
Expires: {new Date(subscription.expirationDate).toLocaleDateString()}
|
|
118
|
-
</Text>
|
|
119
|
-
)}
|
|
120
|
-
|
|
121
|
-
{subscription.willRenew && (
|
|
122
|
-
<Text>Auto-renew: On</Text>
|
|
123
|
-
)}
|
|
124
|
-
</View>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Examples
|
|
130
|
-
|
|
131
|
-
### Conditional Rendering
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
function FeatureList() {
|
|
135
|
-
const { isPremium, isLoading } = usePremium();
|
|
136
|
-
|
|
137
|
-
if (isLoading) return <LoadingSpinner />;
|
|
138
|
-
|
|
139
|
-
return (
|
|
140
|
-
<View>
|
|
141
|
-
<Feature name="Basic Feature" available={true} />
|
|
142
|
-
<Feature name="Premium Feature 1" available={isPremium} />
|
|
143
|
-
<Feature name="Premium Feature 2" available={isPremium} />
|
|
144
|
-
<Feature name="Premium Feature 3" available={isPremium} />
|
|
145
|
-
</View>
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Premium Badge
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
function PremiumBadge() {
|
|
154
|
-
const { isPremium } = usePremium();
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<View style={[
|
|
158
|
-
styles.badge,
|
|
159
|
-
isPremium && styles.badgePremium,
|
|
160
|
-
]}>
|
|
161
|
-
<Text style={styles.badgeText}>
|
|
162
|
-
{isPremium ? '⭐ PREMIUM' : 'FREE'}
|
|
163
|
-
</Text>
|
|
164
|
-
</View>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Premium Gate
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
function PremiumOnlyComponent() {
|
|
173
|
-
const { isPremium, isLoading } = usePremium();
|
|
174
|
-
|
|
175
|
-
if (isLoading) {
|
|
176
|
-
return <ActivityIndicator />;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!isPremium) {
|
|
180
|
-
return (
|
|
181
|
-
<View>
|
|
182
|
-
<Text>This feature requires Premium</Text>
|
|
183
|
-
<Button
|
|
184
|
-
onPress={() => navigation.navigate('Paywall')}
|
|
185
|
-
title="Upgrade to Premium"
|
|
186
|
-
/>
|
|
187
|
-
</View>
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return <PremiumContent />;
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## Behavior
|
|
196
|
-
|
|
197
|
-
### Loading States
|
|
198
|
-
|
|
199
|
-
The hook goes through these states:
|
|
200
|
-
|
|
201
|
-
1. **Initial**: `isLoading = true`, `isPremium = false`
|
|
202
|
-
2. **Loading**: Fetches subscription status
|
|
203
|
-
3. **Loaded**: `isLoading = false`, `isPremium` set to actual value
|
|
204
|
-
4. **Error**: `isLoading = false`, `error` set
|
|
205
|
-
|
|
206
|
-
### Automatic Updates
|
|
207
|
-
|
|
208
|
-
The hook automatically updates when:
|
|
209
|
-
- User logs in/logs out
|
|
210
|
-
- Subscription status changes
|
|
211
|
-
- App comes to foreground
|
|
212
|
-
|
|
213
|
-
### Caching
|
|
214
|
-
|
|
215
|
-
The hook caches subscription status for:
|
|
216
|
-
- Default: 5 minutes
|
|
217
|
-
- Configurable via `staleTime` option
|
|
218
|
-
|
|
219
|
-
## Related Hooks
|
|
220
|
-
|
|
221
|
-
- **usePremiumGate** - For gating premium features
|
|
222
|
-
- **useSubscription** - For more subscription details
|
|
223
|
-
- **useSubscriptionStatus** - For detailed status info
|
|
224
|
-
- **usePremiumWithCredits** - For premium OR credits features
|
|
225
|
-
|
|
226
|
-
## See Also
|
|
227
|
-
|
|
228
|
-
- [usePremiumGate](./usePremiumGate.md)
|
|
229
|
-
- [useSubscription](./useSubscription.md)
|
|
230
|
-
- [usePremiumWithCredits](./usePremiumWithCredits.md)
|
|
5
|
+
## Location
|
|
6
|
+
|
|
7
|
+
**Import Path**: `@umituz/react-native-subscription`
|
|
8
|
+
|
|
9
|
+
**File**: `src/presentation/hooks/usePremium.ts`
|
|
10
|
+
|
|
11
|
+
**Type**: Hook
|
|
12
|
+
|
|
13
|
+
## Strategy
|
|
14
|
+
|
|
15
|
+
### Premium Status Flow
|
|
16
|
+
|
|
17
|
+
1. **Initial Check**: Fetch current subscription status from repository
|
|
18
|
+
2. **Status Evaluation**: Determine if user has active premium subscription
|
|
19
|
+
3. **Real-time Updates**: Automatically update when user logs in/out or subscription changes
|
|
20
|
+
4. **Caching**: Cache status for 5 minutes (configurable) to reduce API calls
|
|
21
|
+
5. **Loading States**: Provide loading indicators during data fetch
|
|
22
|
+
6. **Error Handling**: Handle fetch errors gracefully
|
|
23
|
+
|
|
24
|
+
### Integration Points
|
|
25
|
+
|
|
26
|
+
- **Subscription Repository**: `src/infrastructure/repositories/SubscriptionRepository.ts`
|
|
27
|
+
- **TanStack Query**: For caching and real-time updates
|
|
28
|
+
- **Auth Context**: Sync with user authentication state
|
|
29
|
+
- **RevenueCat**: For subscription data source
|
|
30
|
+
|
|
31
|
+
## Restrictions
|
|
32
|
+
|
|
33
|
+
### REQUIRED
|
|
34
|
+
|
|
35
|
+
- **Loading State**: MUST handle loading state in UI
|
|
36
|
+
- **Error Handling**: MUST handle error state
|
|
37
|
+
- **Check Before Access**: MUST verify isPremium before showing premium features
|
|
38
|
+
|
|
39
|
+
### PROHIBITED
|
|
40
|
+
|
|
41
|
+
- **NEVER** use for security decisions (server-side validation required)
|
|
42
|
+
- **NEVER** assume instant data availability (always check loading state)
|
|
43
|
+
- **DO NOT** use for guest users without proper handling
|
|
44
|
+
|
|
45
|
+
### CRITICAL SAFETY
|
|
46
|
+
|
|
47
|
+
- **ALWAYS** handle loading state before rendering premium content
|
|
48
|
+
- **NEVER** trust client-side state for security enforcement
|
|
49
|
+
- **MUST** implement error boundaries when using this hook
|
|
50
|
+
|
|
51
|
+
## AI Agent Guidelines
|
|
52
|
+
|
|
53
|
+
### When Implementing Premium Features
|
|
54
|
+
|
|
55
|
+
1. **Always** check loading state first
|
|
56
|
+
2. **Always** handle error state
|
|
57
|
+
3. **Always** verify isPremium before showing premium content
|
|
58
|
+
4. **Never** use for security decisions without server validation
|
|
59
|
+
5. **Always** provide upgrade path for non-premium users
|
|
60
|
+
|
|
61
|
+
### Integration Checklist
|
|
62
|
+
|
|
63
|
+
- [ ] Import from correct path: `@umituz/react-native-subscription`
|
|
64
|
+
- [ ] Handle loading state (show ActivityIndicator or skeleton)
|
|
65
|
+
- [ ] Handle error state (show error message)
|
|
66
|
+
- [ ] Check isPremium before rendering premium content
|
|
67
|
+
- [ ] Provide upgrade path for free users
|
|
68
|
+
- [ ] Test with premium user
|
|
69
|
+
- [ ] Test with free user
|
|
70
|
+
- [ ] Test with guest user
|
|
71
|
+
- [ ] Test offline scenario
|
|
72
|
+
|
|
73
|
+
### Common Patterns
|
|
74
|
+
|
|
75
|
+
1. **Conditional Rendering**: Show/hide features based on isPremium
|
|
76
|
+
2. **Premium Badge**: Display premium status badge
|
|
77
|
+
3. **Feature Gating**: Use usePremiumGate instead of manual checks
|
|
78
|
+
4. **Status Display**: Show subscription details with useSubscriptionDetails
|
|
79
|
+
5. **Upgrade Prompts**: Guide free users to paywall
|
|
80
|
+
|
|
81
|
+
## Related Documentation
|
|
82
|
+
|
|
83
|
+
- **usePremiumGate**: Gating premium features
|
|
84
|
+
- **useSubscription**: Detailed subscription status
|
|
85
|
+
- **useSubscriptionStatus**: Subscription status details
|
|
86
|
+
- **usePremiumWithCredits**: Hybrid premium/credits access
|
|
87
|
+
- **Subscription Repository**: `src/infrastructure/repositories/README.md`
|
|
88
|
+
- **Domain Layer**: `src/domain/README.md`
|