Check access
Gate features using the current customer's active perk grants.
The current person snapshot contains entitlements, subscription state, and purchase history. Use entitlement grants to decide what the customer can access.
This page covers checks inside the app. Anything a customer could reach by calling your API directly must also be checked on the server — see Check access from your backend.
Gate a feature
A perk is available when its grant is active:
suspend fun hasPerk(perkId: String): Boolean {
val person = voidhash.getCurrentPerson() ?: return false
return person.activePerkIds.contains(perkId)
}Wrap this once in your app so screens stay simple.
Gate on perks, not subscription status
Subscription status cannot tell you which features a product unlocks, and it misses access from one-time purchases or manual grants. Active perk grants are the access-control source of truth.
Offline and failure behavior
A failed refresh (offline, server error) is not proof that the customer has no access.
getCurrentPerson() throws on failure instead of answering a confident "no". Treat a thrown error
as "unknown" and retry or serve your last known state:
try {
val hasAccess = hasPerk("premium")
// Route to premium content or the upgrade prompt based on hasAccess.
} catch (error: VoidhashException) {
// Unknown — retry or fall back to cached state, never lock by default.
}Read the current person
val person = voidhash.getCurrentPerson()Returns null when no person exists yet for this identity. The snapshot contains entitlements,
subscription state, and purchase history.
Grant fields
| Field | Meaning |
|---|---|
perkId | The perk slug configured in Studio. |
status | active or expired. |
source | subscription, purchase, or manual. |
sourceId | The subscription, purchase, or manual grant that created it. |
expiresAt | Expiration time, or null for access without an expiry. |
Use subscriptions.current for account UI such as the current plan or renewal state. Use
purchases.history when you need to show past transactions.
Refresh behavior
The SDK refreshes the person after purchases, restores, and identity changes. The snapshot is cached
for two days and served stale after five minutes; pass forceFetch = true to force a network
round-trip:
voidhash.getCurrentPerson(forceFetch = true)