Buy the currently selected promoted product.
프로모션된 제품에 대한 결제 프로세스를 시작합니다.
Should only be called in response to the iap-promoted-product event.
buyPromotedProductIOS(): Promise<void>
import React from 'react';
import {Button} from 'react-native';
import {buyPromotedProductIOS} from 'react-native-iap';
const App = () => {
const handleBuy = async () => await buyPromotedProductIOS();
return (
<Button title="Buy" onPress={handleBuy} />
);
}
Clear valid products.
Apple 서버에서 확인한 모든 제품을 제거합니다.
clearProductsIOS(): Promise<void>
import React, {useEffect} from 'react';
import {View} from 'react-native';
import {clearProductsIOS} from 'react-native-iap';
const App = () => {
useEffect(() => {
void clearProductsIOS();
}, []);
return <View />;
}
Clear the remaining transactions.
See https://github.com/dooboolab/react-native-iap/issues/257
See https://github.com/dooboolab/react-native-iap/issues/801
clearTransactionIOS(): Promise<void>
import React, {useEffect} from 'react';
import {View} from 'react-native';
import {clearTransactionIOS} from 'react-native-iap';
const App = () => {
useEffect(() => {
void clearTransactionIOS();
}, [])
return <View />;
}
완료 대기 중인 모든 트랜잭션을 가져옵니다.
getPendingPurchasesIOS(): Promise<Purchase[]>;
import React from 'react';
import {Button} from 'react-native';
import {getPendingPurchasesIOS} from 'react-native-iap';
const App = () => {
const handlePendingPurchases = async () => await getPendingPurchasesIOS();
return (
<Button title="Pending purchases" onPress={handlePendingPurchases} />
)
}
앱스토어에서 제품을 홍보해야 한다.
앱스토어 대신 앱에서 앱스토어 구매를 계속해야 함을 나타냅니다.
getPromotedProductIOS(): Promise<ProductProduct | null>;
import React, {useCallback} from 'react';
import {View} from 'react-native';
import {getPromotedProductIOS} from 'react-native-iap';
const App = () => {
const promotedProduct = useCallback(async () => await getPromotedProductIOS());
return <View />;
}
TODO: works with listener to get the products
현재 영수증을 가져옵니다.
getReceiptIOS(): Promise<string>;
import {useCallback} from 'react';
import {getReceiptIOS} from 'react-native-iap';
const receipt = useCallback(async () => await getReceiptIOS());
App Store Connect에서 생성한 구독 오퍼 코드를 사용자가 상환할 수 있는 시트를 표시합니다.
presentCodeRedemptionSheetIOS(): Promise<null>;
import React from 'react';
import {Button} from 'react-native';
import {presentCodeRedemptionSheetIOS} from 'react-native-iap';
const App = () => {
const handleRedemption = async () => {
await presentCodeRedemptionSheetIOS();
}
return (
<Button title="Redeem" onPress={handleRedemption} />
)
}
오퍼가 있는 제품 또는 구독을 구입합니다.
서버에서 가져와야 하는 일부 정보를 사용하여 결제 프로세스를 실행합니다.
requestPurchaseWithOfferIOS(
/** The product identifier */
sku: Sku,
/** An user identifier on you system */
forUser: string,
/** The offer information */
withOffer: PaymentDiscount,
): Promise<void>
import React from 'react';
import {Button} from 'react-native';
import {requestPurchaseWithOfferIOS} from 'react-native-iap';
const App = () => {
const handlePurchase = async () => {
await requestPurchaseWithOfferIOS({sku: 'productId', forUser: 'user-id', withOffer: {
identifier: 'string',
keyIdentifier: 'string',
nonce: 'string',
signature: 'string',
timestamp: Date.now(),
}});
}
return (
<Button title="Buy" onPress={handlePurchase} />
);
}
제품에 대한 수량이 포함된 구매를 요청합니다.
응답은 PurchaseUpdateListener를 통해 수신됩니다.
requestPurchaseWithQuantityIOS(
/** The product's sku/ID */
sku: Sku,
/** The quantity to request to buy */
quantity: number,
): Promise<ProductPurchase>
import React from 'react';
import {Button} from 'react-native';
import {requestPurchaseWithQuantityIOS} from 'react-native-iap';
const App = () => {
const handlePurchase = async () => {
await requestPurchaseWithQuantityIOS('productId', 2);
}
return (
<Button title="Purchase" onPress={handlePurchase} />
);
}
영수증을 확인합니다.
validateReceiptIOS(
/** The receipt body to send to apple server. */
receiptBody: Record<string, unknown>,
/** Whether this is in test environment which is sandbox. */
isTest?: boolean,
): Promise<ResponseBody>
import React from 'react';
import {Button} from 'react-native';
import {validateReceiptIOS} from 'react-native-iap';
const App = () => {
const handleValidate = async () => {
await validateReceiptIOS({
'receipt-data': '...',
});
}
return (
<Button title="Validate" onPress={handleValidate} />
);
}