diff --git a/src/hooks/useIAP.ts b/src/hooks/useIAP.ts index d2fe4d3f9..df510f3fc 100644 --- a/src/hooks/useIAP.ts +++ b/src/hooks/useIAP.ts @@ -52,6 +52,7 @@ export const useIAP = (): IAP_STATUS => { currentPurchase, currentPurchaseError, initConnectionError, + setConnected, setProducts, setSubscriptions, setAvailablePurchases, @@ -119,7 +120,10 @@ export const useIAP = (): IAP_STATUS => { ); useEffect(() => { + setConnected(true); + return () => { + setConnected(false); setCurrentPurchaseError(undefined); }; // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/hooks/withIAPContext.tsx b/src/hooks/withIAPContext.tsx index 3b978f91d..127a3a5c6 100644 --- a/src/hooks/withIAPContext.tsx +++ b/src/hooks/withIAPContext.tsx @@ -28,6 +28,7 @@ type IAPContextType = { currentTransaction?: TransactionSk2; currentPurchaseError?: PurchaseError; initConnectionError?: Error; + setConnected: (connected: boolean) => void; setProducts: (products: Product[]) => void; setSubscriptions: (subscriptions: Subscription[]) => void; setPurchaseHistory: (purchaseHistory: Purchase[]) => void; @@ -86,6 +87,7 @@ export function withIAPContext(Component: React.ComponentType) { currentTransaction, currentPurchaseError, initConnectionError, + setConnected, setProducts, setSubscriptions, setPurchaseHistory, @@ -104,6 +106,7 @@ export function withIAPContext(Component: React.ComponentType) { currentTransaction, currentPurchaseError, initConnectionError, + setConnected, setProducts, setSubscriptions, setPurchaseHistory,