From ff037e3f13bd82aff875ce249fabbbd9d079f910 Mon Sep 17 00:00:00 2001 From: hyochan Date: Sun, 27 Oct 2024 15:17:47 +0900 Subject: [PATCH] fix: tsc --- src/useIap.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/useIap.ts b/src/useIap.ts index a7aecdf..0276487 100644 --- a/src/useIap.ts +++ b/src/useIap.ts @@ -1,21 +1,25 @@ -import RNIap, { +import { endConnection, initConnection, purchaseErrorListener, purchaseUpdatedListener, transactionUpdatedIos, -} from '../'; + getProducts, + getAvailablePurchases, + getPurchaseHistory, + getSubscriptions, +} from './'; import {useCallback, useEffect, useState} from 'react'; import { Product, ProductPurchase, + Purchase, PurchaseError, PurchaseResult, SubscriptionProduct, SubscriptionPurchase, } from './ExpoIap.types'; -import {Purchase} from '../build/ExpoIap.types'; import {TransactionEvent} from './modules/ios'; import {TransactionSk2} from './types/ExpoIapIos.types'; import {Subscription} from 'expo-modules-core'; @@ -66,23 +70,23 @@ export function useIAP(): IAP_STATUS { const [currentPurchaseError, setCurrentPurchaseError] = useState(); - const getProducts = useCallback(async (skus: string[]): Promise => { - setProducts(await RNIap.getProducts(skus)); + const requestProducts = useCallback(async (skus: string[]): Promise => { + setProducts(await getProducts(skus)); }, []); - const getSubscriptions = useCallback( + const requestSubscriptions = useCallback( async (skus: string[]): Promise => { - setSubscriptions(await RNIap.getSubscriptions(skus)); + setSubscriptions(await getSubscriptions(skus)); }, [], ); - const getAvailablePurchases = useCallback(async (): Promise => { - setAvailablePurchases(await RNIap.getAvailablePurchases()); + const requestAvailablePurchases = useCallback(async (): Promise => { + setAvailablePurchases(await getAvailablePurchases()); }, []); - const getPurchaseHistories = useCallback(async (): Promise => { - setPurchaseHistories(await RNIap.getPurchaseHistory()); + const requestPurchaseHistories = useCallback(async (): Promise => { + setPurchaseHistories(await getPurchaseHistory()); }, []); const finishTransaction = useCallback( @@ -176,9 +180,9 @@ export function useIAP(): IAP_STATUS { availablePurchases, currentPurchase, currentPurchaseError, - getProducts, - getSubscriptions, - getAvailablePurchases, - getPurchaseHistories, + getProducts: requestProducts, + getSubscriptions: requestSubscriptions, + getAvailablePurchases: requestAvailablePurchases, + getPurchaseHistories: requestPurchaseHistories, }; }