Skip to content

Commit 4dc9639

Browse files
committed
fix: apply codereview in #184
1 parent e4d4bfe commit 4dc9639

30 files changed

+123
-93
lines changed

docs/blog/2025-09-05-v2-9-0-release.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ Following [OpenIAP v1.1.0 specification](https://www.openiap.dev/docs/versions#v
7272

7373
```typescript
7474
// ❌ Old
75-
import {IapEvent} from 'expo-iap';
75+
import {OpenIapEvent} from 'expo-iap';
7676

77-
purchaseUpdatedListener((purchase) => {}, IapEvent.PurchaseUpdated);
77+
purchaseUpdatedListener((purchase) => {}, OpenIapEvent.PurchaseUpdated);
7878

7979
// ✅ New
8080
import {OpenIapEvent} from 'expo-iap';

docs/docs/api/methods/core-methods.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const fetchStorefront = async () => {
128128

129129
**Note:** This is useful for region-specific pricing, content, or features.
130130

131-
## getAppTransaction()
131+
## getAppTransactionIOS()
132132

133133
Gets app transaction information for iOS apps (iOS 16.0+). AppTransaction represents the initial purchase that unlocked the app, useful for premium apps or apps that were previously paid.
134134

@@ -139,11 +139,11 @@ Gets app transaction information for iOS apps (iOS 16.0+). AppTransaction repres
139139
> - If built with older SDK versions, the method will throw an error
140140
141141
```tsx
142-
import {getAppTransaction} from 'expo-iap';
142+
import {getAppTransactionIOS} from 'expo-iap';
143143

144144
const fetchAppTransaction = async () => {
145145
try {
146-
const appTransaction = await getAppTransaction();
146+
const appTransaction = await getAppTransactionIOS();
147147
if (appTransaction) {
148148
console.log('App Transaction ID:', appTransaction.appTransactionID);
149149
console.log(

docs/docs/examples/complete-impl.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ useEffect(() => {
4444

4545
const initializeStore = async () => {
4646
try {
47-
await requestProducts({skus: productSkus, type: 'inapp'});
48-
await requestProducts({skus: subscriptionSkus, type: 'subs'});
47+
await fetchProducts({skus: productSkus, type: 'inapp'});
48+
await fetchProducts({skus: subscriptionSkus, type: 'subs'});
4949
} catch (error) {
5050
console.error('Failed to initialize store:', error);
5151
}
@@ -246,8 +246,8 @@ export default function Store() {
246246

247247
// Load both products and subscriptions
248248
await Promise.all([
249-
requestProducts({skus: PRODUCT_IDS, type: 'inapp'}),
250-
requestProducts({skus: SUBSCRIPTION_IDS, type: 'subs'}),
249+
fetchProducts({skus: PRODUCT_IDS, type: 'inapp'}),
250+
fetchProducts({skus: SUBSCRIPTION_IDS, type: 'subs'}),
251251
]);
252252

253253
console.log('Products loaded successfully');

docs/docs/getting-started/setup-android.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ function App() {
5252
React.useEffect(() => {
5353
if (connected) {
5454
// Fetch products and subscriptions
55-
requestProducts({
55+
fetchProducts({
5656
skus: androidProductIds.filter((id) => !id.includes('subscription')),
5757
type: 'inapp',
5858
});
59-
requestProducts({
59+
fetchProducts({
6060
skus: androidProductIds.filter((id) => id.includes('subscription')),
6161
type: 'subs',
6262
});

docs/docs/guides/ios-subscription-offers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type SubscriptionOffer = {
5656
```typescript
5757
import {requestProducts} from 'expo-iap';
5858

59-
const subscriptions = await requestProducts({
59+
const subscriptions = await fetchProducts({
6060
skus: ['com.example.premium'],
6161
type: 'subs',
6262
});
@@ -103,7 +103,7 @@ Use the `isEligibleForIntroOffer` property to check if a user can redeem an intr
103103

104104
```typescript
105105
const checkEligibility = async () => {
106-
const subscriptions = await requestProducts({
106+
const subscriptions = await fetchProducts({
107107
skus: ['com.example.premium'],
108108
type: 'subs',
109109
});

docs/docs/guides/lifecycle.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function App() {
5050
if (connected) {
5151
console.log('Connected to store');
5252
// You can now safely call store methods
53-
requestProducts({skus: ['product1', 'product2'], type: 'inapp'});
53+
fetchProducts({skus: ['product1', 'product2'], type: 'inapp'});
5454
}
5555
}, [connected, requestProducts]);
5656

@@ -227,7 +227,7 @@ function MyApp() {
227227

228228
useEffect(() => {
229229
if (connected) {
230-
requestProducts({skus: productIds, type: 'inapp'});
230+
fetchProducts({skus: productIds, type: 'inapp'});
231231
}
232232
}, [connected]);
233233

docs/docs/guides/migration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,11 @@ The `IapEvent` enum has been renamed to `OpenIapEvent` to align with the OpenIAP
262262

263263
```tsx
264264
// ❌ Before v2.9.0
265-
import {IapEvent} from 'expo-iap';
265+
import {OpenIapEvent} from 'expo-iap';
266266

267267
purchaseUpdatedListener((purchase) => {
268268
console.log('Purchase updated');
269-
}, IapEvent.PurchaseUpdated);
269+
}, OpenIapEvent.PurchaseUpdated);
270270

271271
// ✅ After v2.9.0
272272
import {OpenIapEvent} from 'expo-iap';

docs/docs/guides/purchases.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ For a comprehensive understanding of the purchase lifecycle, see our [Purchase L
2525

2626
## Purchase Flow Overview
2727

28-
Once you have called `requestProducts()`, and have a valid response, you can call `requestPurchase()`. Subscribable products can be purchased just like consumable products and users can cancel subscriptions by using the iOS System Settings.
28+
Once you have called `fetchProducts()`, and have a valid response, you can call `requestPurchase()`. Subscribable products can be purchased just like consumable products and users can cancel subscriptions by using the iOS System Settings.
2929

3030
Before you request any purchase, you should set `purchaseUpdatedListener` from `expo-iap`. It is recommended that you start listening to updates as soon as your application launches. And don't forget that even at launch you may receive successful purchases that either completed while your app was closed or that failed to be finished, consumed or acknowledged due to network errors or bugs.
3131

@@ -180,8 +180,8 @@ export default function PurchaseScreen() {
180180
const initializeIAP = async () => {
181181
try {
182182
// Get both products and subscriptions
183-
await requestProducts({skus: bulbPackSkus, type: 'inapp'});
184-
await requestProducts({skus: subscriptionSkus, type: 'subs'});
183+
await fetchProducts({skus: bulbPackSkus, type: 'inapp'});
184+
await fetchProducts({skus: subscriptionSkus, type: 'subs'});
185185
setIsReady(true);
186186
} catch (error) {
187187
console.error('Error initializing IAP:', error);

docs/docs/intro.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Load your products when the store connects:
7171
useEffect(() => {
7272
if (connected) {
7373
// Fetch your products
74-
requestProducts({skus: productIds, type: 'inapp'});
74+
fetchProducts({skus: productIds, type: 'inapp'});
7575
}
7676
}, [connected]);
7777
```
@@ -161,7 +161,7 @@ export default function SimpleStore() {
161161
const {
162162
connected,
163163
products,
164-
requestProducts,
164+
fetchProducts,
165165
requestPurchase,
166166
currentPurchase,
167167
finishTransaction,
@@ -171,7 +171,7 @@ export default function SimpleStore() {
171171

172172
useEffect(() => {
173173
if (connected) {
174-
requestProducts({skus: productIds, type: 'inapp'});
174+
fetchProducts({skus: productIds, type: 'inapp'});
175175
}
176176
}, [connected]);
177177

docs/versioned_docs/version-2.9/api/index.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ Comprehensive list of all error codes that can be returned by Expo IAP.
3232
import {useIAP} from 'expo-iap';
3333

3434
function MyComponent() {
35-
const {products, purchaseProduct, restorePurchases, isLoading, error} =
36-
useIAP();
35+
const {
36+
products,
37+
subscriptions,
38+
fetchProducts,
39+
requestPurchase,
40+
availablePurchases,
41+
currentPurchaseError,
42+
} = useIAP();
3743

3844
// Your component logic here
3945
}

0 commit comments

Comments
 (0)