Skip to content

Commit

Permalink
Update purchases.mdx (#2845)
Browse files Browse the repository at this point in the history
Fix android purchase params.
  • Loading branch information
anhtuank7c authored Sep 21, 2024
1 parent 2d798aa commit 30dddce
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions docs/docs/guides/purchases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,20 @@ class App extends Component {
Then define the method like below and call it when user press the button.

```tsx
import { requestPurchase, requestSubscription } from 'react-native-iap';
import { Platform } from 'react-native';
import { requestPurchase, requestSubscription, RequestPurchase } from 'react-native-iap';
...
class App extends Component {
purchase = async (sku: string) => {
try {
await requestPurchase({
let purchaseParams: RequestPurchase = {
sku,
andDangerouslyFinishTransactionAutomaticallyIOS: false,
});
};
if (Platform.OS === 'android') {
purchaseParams = { skus: [sku] };
}
await requestPurchase(purchaseParams);
} catch (err) {
console.warn(err.code, err.message);
}
Expand Down

0 comments on commit 30dddce

Please sign in to comment.