Hooks
consume()
Consume a Google Play purchase token from the Expo hooks or compat API.
Purpose
Consumes a Google Play purchase token so the item can be purchased again. Use this for consumable Android purchases after granting the benefit. The hooks and compat APIs also expose the method on iOS, where it is a no-op that resolves with the given token.
Signature
Hooks API:
const { consume } = useSuperwall()
const token = await consume(purchaseToken)Compat API:
import Superwall from "expo-superwall/compat"
const superwall = await Superwall.configure({ apiKey: "YOUR_API_KEY" })
const token = await superwall.consume(purchaseToken)Parameters
Prop
Type
Returns / State
Returns a Promise<string> that resolves to the consumed purchase token on Android. On iOS, it resolves to the given token without consuming anything.
The promise rejects if the native Android consume operation fails. Configure the SDK before calling this method.
Usage
import { Button } from "react-native"
import { useSuperwall } from "expo-superwall"
function ConsumeButton({ purchaseToken }: { purchaseToken: string }) {
const { consume } = useSuperwall()
const consumePurchase = async () => {
try {
const token = await consume(purchaseToken)
console.log("Purchase consumed:", token)
} catch (error) {
console.error("Failed to consume purchase:", error)
}
}
return <Button title="Consume purchase" onPress={consumePurchase} />
}Related
useSuperwall- Hook access to the main Expo SDK store.getPresentationResult()- Another Expo compat API surface with dedicated reference docs.
How is this guide?