Purpl Docs
Entitlements and restoration
Check current access and restore Google Play purchases.
Check entitlements
Kotlin
val customerInfo = purchases.customerInfo()
if (customerInfo.isEntitlementActive("plus")) {
enablePremiumFeatures()
}In Google Play mode, CustomerInfo verifies the signatures of current Play purchases and matches them to products in PurchaseConfiguration. Device verification cannot determine reliable expiration dates or the current base plan, so expiresAt, basePlanIdentifier, and offerIdentifier are null.
Observe entitlement state in Compose
customerInfoFlow is a StateFlow that delivers a new CustomerInfo whenever purchases, restoration, or returning to the app change access. Observe it in Compose with collectAsStateWithLifecycle.
Compose
@Composable
fun PlusScreen(purchases: Purchases) {
val customerInfo by purchases.customerInfoFlow.collectAsStateWithLifecycle()
val hasPlusAccess = customerInfo?.isEntitlementActive("plus") == true
ContentScreen(hasPlusAccess = hasPlusAccess)
}Restore purchases
Kotlin
val customerInfo = purchases.restorePurchases()