|
92 | 92 | Example:
|
93 | 93 |
|
94 | 94 | ```ts
|
95 |
| -const { fetchProducts, products } = useIAP() |
96 |
| -await fetchProducts({ skus: ['p1'] }) |
| 95 | +const {fetchProducts, products} = useIAP(); |
| 96 | +await fetchProducts({skus: ['p1']}); |
97 | 97 | // then read products from state
|
98 | 98 | ```
|
99 | 99 |
|
@@ -145,11 +145,11 @@ Usage example:
|
145 | 145 | try {
|
146 | 146 | await requestPurchase({
|
147 | 147 | /* ... */
|
148 |
| - }) |
| 148 | + }); |
149 | 149 | } catch (e) {
|
150 |
| - const err = parseErrorStringToJsonObj(e) |
151 |
| - if (isUserCancelledError(err)) return |
152 |
| - console.error('IAP failed:', err.code, err.message) |
| 150 | + const err = parseErrorStringToJsonObj(e); |
| 151 | + if (isUserCancelledError(err)) return; |
| 152 | + console.error('IAP failed:', err.code, err.message); |
153 | 153 | }
|
154 | 154 | ```
|
155 | 155 |
|
@@ -201,20 +201,20 @@ try {
|
201 | 201 |
|
202 | 202 | ```ts
|
203 | 203 | // src/specs/RnIap.nitro.ts
|
204 |
| -export type Purchase = { id: string; productId: string; date: Date } |
| 204 | +export type Purchase = {id: string; productId: string; date: Date}; |
205 | 205 | export type Result<T> =
|
206 |
| - | { kind: 'ok'; value: T } |
207 |
| - | { kind: 'err'; code: string; message: string } |
| 206 | + | {kind: 'ok'; value: T} |
| 207 | + | {kind: 'err'; code: string; message: string}; |
208 | 208 |
|
209 | 209 | export interface RnIapSpec {
|
210 |
| - init(): Promise<void> |
211 |
| - fetchProducts(ids: string[]): Promise<Product[]> |
| 210 | + init(): Promise<void>; |
| 211 | + fetchProducts(ids: string[]): Promise<Product[]>; |
212 | 212 | requestPurchase(
|
213 | 213 | id: string,
|
214 |
| - opts?: { quantity?: number } |
215 |
| - ): Promise<Result<Purchase>> |
216 |
| - addPurchaseListener(cb: (p: Purchase) => void): void |
217 |
| - getStorefrontIOS?(): string |
| 214 | + opts?: {quantity?: number}, |
| 215 | + ): Promise<Result<Purchase>>; |
| 216 | + addPurchaseListener(cb: (p: Purchase) => void): void; |
| 217 | + getStorefrontIOS?(): string; |
218 | 218 | }
|
219 | 219 | ```
|
220 | 220 |
|
|
0 commit comments