Skip to main content

IapIos

react-native-iap / Exports / IapIos

Namespace: IapIos

Table of contents

Interfaces

Type Aliases

Functions

Type Aliases

BuyProduct

Ƭ BuyProduct: (sku: Sku, andDangerouslyFinishTransactionAutomaticallyIOS: boolean, applicationUsername: string | undefined, quantity: number, withOffer: Record\<keyof PaymentDiscount, string> | undefined) => Promise\<Purchase>

Type declaration

▸ (sku, andDangerouslyFinishTransactionAutomaticallyIOS, applicationUsername, quantity, withOffer): Promise\<Purchase>

Parameters
NameType
skuSku
andDangerouslyFinishTransactionAutomaticallyIOSboolean
applicationUsernamestring | undefined
quantitynumber
withOfferRecord\<keyof PaymentDiscount, string> | undefined
Returns

Promise\<Purchase>

Defined in

modules/ios.ts:23

Functions

buyPromotedProductIOS

buyPromotedProductIOS(): Promise\<void>

Buy the currently selected promoted product (iOS only) Initiates the payment process for a promoted product. Should only be called in response to the iap-promoted-product event.

Returns

Promise\<void>

Defined in

modules/ios.ts:136


clearProductsIOS

clearProductsIOS(): Promise\<void>

Clear valid Products (iOS only) Remove all products which are validated by Apple server.

Returns

Promise\<void>

Defined in

modules/ios.ts:225


clearTransactionIOS

clearTransactionIOS(): Promise\<void>

Clear Transaction (iOS only) Finish remaining transactions. Related to issue #257 and #801 link : https://github.com/hyochan/react-native-iap/issues/257 https://github.com/hyochan/react-native-iap/issues/801

Returns

Promise\<void>

Defined in

modules/ios.ts:217


deepLinkToSubscriptionsIos

deepLinkToSubscriptionsIos(): Promise\<void>

Returns

Promise\<void>

Defined in

modules/ios.ts:228


getPendingPurchasesIOS

getPendingPurchasesIOS(): Promise\<ProductPurchase[]>

Get the current receipt base64 encoded in IOS.

Returns

Promise\<ProductPurchase[]>

Defined in

modules/ios.ts:61


getPromotedProductIOS

getPromotedProductIOS(): Promise\<null | ProductIOS>

Should Add Store Payment (iOS only) Indicates the the App Store purchase should continue from the app instead of the App Store.

Returns

Promise\<null | ProductIOS>

promoted product

Defined in

modules/ios.ts:123


getReceiptIOS

getReceiptIOS(Requests): Promise\<undefined | null | string>

Get the current receipt base64 encoded in IOS.

The sequence should be as follows: Call getReceiptIOS({forceRefresh: false}). That will return the cached receipt that is available on TestFlight and Production. In the case of Sandbox the receipt might not be cached, causing it to return nil. In that case you might want to let the user that they will to be prompted for credentials. If they accept, call it again with `getReceiptIOS({forceRefresh:true}) If it fails or the user declines, assume they haven't purchased any items. Reference: https://developer.apple.com/forums/thread/662350

From: https://apphud.com/blog/app-store-receipt-validation#what-is-app-store-receipt

Q: Does a receipt always exist in the app? A: If a user downloaded the app from the App Store – yes. However, in sandbox if your app was installed via Xcode or Testflight, then there won't be a receipt until you make a purchase or restore.

Usage

import {getReceiptIOS} from 'react-native-iap';
try{
let receipt = await getReceiptIOS({forceRefresh: false});
if(!receipt){
// Let user know that they might get prompted for credentials
const shouldShowPrompt = // Display UI with details, Did user agree?. this only for Sandbox testing
if(shouldShowPrompt){
receipt = await getReceiptIOS({forceRefresh: true});
}
}
}catch(error:Error){
// error while getting the receipt, it might indicate an invalid receipt of a connection error while trying to get it
}
// If !receipt assume user doesn't own the items

Parameters

NameTypeDescription
RequestsObjectthe receipt from Bundle.main.appStoreReceiptURL. Based on the note above, looks like forceRefresh only makes sense when testing an app not downloaded from the Appstore. And only afer a direct user action.
Requests.forceRefresh?boolean-

Returns

Promise\<undefined | null | string>

The receipt data

Defined in

modules/ios.ts:100


presentCodeRedemptionSheetIOS

presentCodeRedemptionSheetIOS(): Promise\<null>

Launches a modal to register the redeem offer code in IOS.

Returns

Promise\<null>

Defined in

modules/ios.ts:115


validateReceiptIos

validateReceiptIos(«destructured»): Promise\<false | ResponseBody>

Validate receipt for iOS.

Parameters

NameType
«destructured»Object
› isTest?boolean
› receiptBodyRecord\<string, unknown>

Returns

Promise\<false | ResponseBody>

Defined in

modules/ios.ts:190