Skip to content

Commit 88ee1af

Browse files
committed
feat: add standardized DiscountOffer and SubscriptionOffer types
- Add new cross-platform types: DiscountOffer, SubscriptionOffer, DiscountOfferType, PaymentMode, SubscriptionPeriod, SubscriptionPeriodUnit - Use flat structure with platform-specific suffixes (offerTokenAndroid, keyIdentifierIOS, etc.) - Deprecate old platform-specific types for migration path - Update Android BillingConverters to populate new standardized fields - Update iOS StoreKitTypesBridge to convert StoreKit offers to standardized types - Add Horizon flavor support with null/empty defaults - Add comprehensive unit tests for both platforms - Update example apps to use new standardized offer types - Add documentation page for offer types
1 parent 0e245f4 commit 88ee1af

28 files changed

Lines changed: 7073 additions & 89 deletions

File tree

.claude/commands/sync-all-platforms.md

Lines changed: 451 additions & 0 deletions
Large diffs are not rendered by default.

.claude/commands/sync-expo-iap.md

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
# Sync Changes to expo-iap
2+
3+
Synchronize OpenIAP changes to the [expo-iap](https://github.com/hyochan/expo-iap) repository.
4+
5+
**Target Repository:** `/Users/hyo/Github/hyochan/expo-iap`
6+
7+
## Project Overview
8+
9+
- **Package Manager:** Bun
10+
- **Framework:** Expo Module (React Native)
11+
- **Current Version:** Check `package.json`
12+
- **OpenIAP Version Tracking:** `openiap-versions.json`
13+
14+
## Key Files
15+
16+
| File | Purpose | Auto-Generated |
17+
|------|---------|----------------|
18+
| `src/types.ts` | TypeScript types from OpenIAP | YES |
19+
| `src/index.ts` | Main API exports | NO |
20+
| `src/useIAP.ts` | React Hook for IAP | NO |
21+
| `src/modules/ios.ts` | iOS-specific functions | NO |
22+
| `src/modules/android.ts` | Android-specific functions | NO |
23+
| `openiap-versions.json` | Version tracking | NO |
24+
25+
## Sync Steps
26+
27+
### 0. Pull Latest (REQUIRED)
28+
29+
**Always pull the latest code before starting any sync work:**
30+
31+
```bash
32+
cd /Users/hyo/Github/hyochan/expo-iap
33+
git pull
34+
```
35+
36+
### 1. Type Synchronization
37+
38+
```bash
39+
cd /Users/hyo/Github/hyochan/expo-iap
40+
41+
# Update version in openiap-versions.json
42+
# Edit "gql" field to new version
43+
44+
# Download and regenerate types
45+
bun run generate:types
46+
47+
# Verify types
48+
bun run typecheck
49+
```
50+
51+
### 2. Native Code Modifications
52+
53+
#### iOS Native Code
54+
55+
**Location:** `ios/`
56+
57+
Key files to update:
58+
- `ios/ExpoIapModule.swift` - Main Expo module implementation
59+
- `ios/ExpoIap.podspec` - CocoaPods spec (update `apple` version dependency)
60+
61+
**When to modify:**
62+
- New iOS-specific API methods added to OpenIAP
63+
- Type conversion changes needed
64+
- StoreKit 2 API changes
65+
66+
**Update workflow:**
67+
```bash
68+
cd /Users/hyo/Github/hyochan/expo-iap
69+
70+
# 1. Update apple version in openiap-versions.json
71+
# 2. Review openiap/packages/apple/Sources/ for changes
72+
# 3. Update ios/ExpoIapModule.swift accordingly
73+
74+
# Install updated pod
75+
cd example/ios && pod install --repo-update
76+
```
77+
78+
#### Android Native Code
79+
80+
**Location:** `android/src/main/java/`
81+
82+
Key files to update:
83+
- `ExpoIapModule.kt` - Main Expo module implementation
84+
- `build.gradle` - Dependencies (auto-reads `google` version)
85+
86+
**When to modify:**
87+
- New Android-specific API methods added to OpenIAP
88+
- Type conversion changes needed
89+
- Play Billing API changes
90+
91+
**Update workflow:**
92+
```bash
93+
cd /Users/hyo/Github/hyochan/expo-iap
94+
95+
# 1. Update google version in openiap-versions.json
96+
# 2. Review openiap/packages/google/openiap/src/main/ for changes
97+
# 3. Update android/src/main/java/ accordingly
98+
99+
# Gradle auto-syncs on build
100+
```
101+
102+
### 3. Build & Test Native Code
103+
104+
#### iOS Build Test
105+
106+
```bash
107+
cd /Users/hyo/Github/hyochan/expo-iap/example
108+
109+
# Clean and prebuild
110+
npx expo prebuild --clean --platform ios
111+
112+
# Install pods
113+
cd ios && pod install --repo-update && cd ..
114+
115+
# Build for simulator
116+
npx expo run:ios --device "iPhone 15 Pro"
117+
118+
# Or build via Xcode
119+
open ios/expoiapexample.xcworkspace
120+
# Build: Cmd+B, Run: Cmd+R
121+
```
122+
123+
#### Android Build Test
124+
125+
```bash
126+
cd /Users/hyo/Github/hyochan/expo-iap/example
127+
128+
# Clean and prebuild
129+
npx expo prebuild --clean --platform android
130+
131+
# Build debug APK
132+
npx expo run:android
133+
134+
# Or build via Android Studio
135+
# Open android/ folder in Android Studio
136+
# Build > Make Project
137+
```
138+
139+
#### Android Horizon Build (Meta Quest)
140+
141+
```bash
142+
cd /Users/hyo/Github/hyochan/expo-iap/example
143+
144+
# Enable Horizon flavor in gradle.properties
145+
echo "horizonEnabled=true" >> android/gradle.properties
146+
147+
# Prebuild and build with Horizon
148+
npx expo prebuild --clean --platform android
149+
npx expo run:android
150+
151+
# Revert for Play Store builds
152+
sed -i '' '/horizonEnabled=true/d' android/gradle.properties
153+
```
154+
155+
#### Full Build Matrix
156+
157+
```bash
158+
cd /Users/hyo/Github/hyochan/expo-iap
159+
160+
# TypeScript build
161+
bun run build
162+
163+
# iOS build
164+
cd example && npx expo run:ios
165+
166+
# Android build (Play Store)
167+
cd example && npx expo run:android
168+
169+
# Android build (Horizon)
170+
cd example && echo "horizonEnabled=true" >> android/gradle.properties && npx expo run:android
171+
172+
# All tests
173+
bun run test
174+
cd example && bun run test
175+
```
176+
177+
### 3. Update Example Code
178+
179+
**Location:** `example/app/`
180+
181+
Key example screens:
182+
- `index.tsx` - Home/Overview
183+
- `purchase-flow.tsx` - Purchase flow demo
184+
- `subscription-flow.tsx` - Subscription demo
185+
- `alternative-billing.tsx` - Android alt billing
186+
- `offer-code.tsx` - Promo code redemption
187+
188+
### 4. Update Tests
189+
190+
**Library Tests:** `src/__tests__/`
191+
**Example Tests:** `example/__tests__/`
192+
193+
```bash
194+
# Run all tests
195+
bun run test
196+
197+
# Run example tests
198+
cd example && bun run test
199+
```
200+
201+
### 5. Update Documentation
202+
203+
**Location:** `docs/`
204+
- `docs/api/` - API reference
205+
- `docs/guides/` - Usage guides
206+
- `docs/examples/` - Code examples
207+
208+
### 6. Update llms.txt Files
209+
210+
**Location:** `docs/static/`
211+
212+
Update AI-friendly documentation files when APIs or types change:
213+
214+
- `docs/static/llms.txt` - Quick reference for AI assistants
215+
- `docs/static/llms-full.txt` - Detailed AI reference
216+
217+
**When to update:**
218+
- New API functions added
219+
- Function signatures changed
220+
- New types or enums added
221+
- Usage patterns updated
222+
- Error codes changed
223+
224+
**Content to sync:**
225+
1. Installation commands
226+
2. Core API reference (useIAP hook, direct functions)
227+
3. Key types (Product, Purchase, ErrorCode)
228+
4. Common usage patterns
229+
5. Platform-specific APIs (iOS/Android suffixes)
230+
6. Error handling examples
231+
232+
### 7. Pre-commit Checklist
233+
234+
```bash
235+
bun run lint # ESLint
236+
bun run typecheck # TypeScript
237+
bun run test # Jest
238+
cd example && bun run test # Example app tests
239+
```
240+
241+
## Naming Conventions
242+
243+
- **iOS-only:** `functionNameIOS` (e.g., `syncIOS`, `getPromotedProductIOS`)
244+
- **Android-only:** `functionNameAndroid` (e.g., `validateReceiptAndroid`)
245+
- **Cross-platform:** No suffix (e.g., `fetchProducts`, `requestPurchase`)
246+
- **Error codes:** kebab-case (e.g., `'user-cancelled'`)
247+
248+
## Deprecation Check
249+
250+
Search for deprecated patterns:
251+
```bash
252+
cd /Users/hyo/Github/hyochan/expo-iap
253+
grep -r "@deprecated" src/
254+
grep -r "DEPRECATED" src/
255+
```
256+
257+
Known deprecated functions:
258+
- `requestProducts` -> Use `fetchProducts`
259+
- `validateReceipt` -> Use `verifyPurchase`
260+
- `validateReceiptIOS` -> Use `verifyPurchase`
261+
262+
## Commit Message Format
263+
264+
```
265+
feat: add discount offer support
266+
fix: resolve iOS purchase verification
267+
docs: update subscription flow guide
268+
```
269+
270+
## References
271+
272+
- **CLAUDE.md:** `/Users/hyo/Github/hyochan/expo-iap/CLAUDE.md`
273+
- **OpenIAP Docs:** https://openiap.dev/docs
274+
- **expo-iap Docs:** https://expo-iap.vercel.app

0 commit comments

Comments
 (0)