consume()
Consumes an in-app purchase by its purchase token.
Purpose
Consumes a consumable in-app purchase using its purchase token. This is typically used for Google Play Store purchases that need to be consumed before they can be purchased again.
Signature
Future<String> consume(String purchaseToken)Parameters
Prop
Type
Returns / State
Returns a Future<String> that resolves to the purchase token of the consumed purchase.
Usage
Consuming a purchase after you have granted the benefit:
Future<void> consumeGrantedPurchase(String purchaseToken) async {
try {
final consumedToken = await Superwall.shared.consume(purchaseToken);
print('Purchase consumed: $consumedToken');
} catch (e) {
print('Failed to consume purchase: $e');
}
}On Android, purchaseToken comes from Google Play's purchase result. The current Flutter StoreTransaction wrapper does not expose this token from Superwall's transactionComplete event.
Related
PurchaseController- Handles purchase logicConsumable Products- End-to-end setup for consumable products
How is this guide?