VoidhashDocs
DevelopersHelp centerGuidesAPI reference
Dashboard
Get started
Introduction
Quickstart
How Voidhash works
Glossary
Versions and releases
Concepts
Teams, projects and environments
API keys
Products and perks
Offers
Subscription lifecycle
People and identity
Events
Features
Paywalls in your app
Feature flags and A/B tests
Paywall components
Push notifications
Ad attribution in your app
Client SDKs
React Native
Swift
Kotlin
Web
Your backend
Node.js
PHP
Go
Rust
Other languages
Payment sources
Forward store notifications
Developer tools
CLI
MCP server
Query analytics with VoidQL
Kotlin SDK
Kotlin quickstart
Display a paywall
Make and restore purchases
Check access
Identify users
Evaluate feature flags
Capture analytics
Track screens
Development mode
Kotlin SDK reference
Errors
Diagnostic codes
Troubleshooting

Kotlin SDK reference

Client options, methods, caching and shutdown of the Voidhash Android SDK.

Everything VoidhashOptions accepts and the client exposes. To install the SDK and create the client, see Kotlin SDK.

Client options

OptionDefaultDescription
baseUrlhttps://api.voidhash.comAPI origin, for self-hosting.
ingestUrlbaseUrlAnalytics origin.
debugfalseLogs SDK warnings to logcat under the tag Voidhash and marks requests as debug traffic.
distinctIdGeneratedStarts with this user ID and links the device's anonymous ID to it. Usually call identify instead.
enabledtruefalse makes the client inert. See Disabled clients.
readOnlyfalseObserver mode: records purchases, never acknowledges or consumes them, and refuses purchase.
devfalseBuys from a simulated store in debug builds. See Development mode.
paywallRenderernullDraws flows; pass VoidhashUiPaywallRenderer(). See Paywalls.
flowCapabilitiessetOf(FlowCapability.LINKS)What flows may do. See Grant capabilities.
preloadPlacementsemptyList()Locations whose flows are cached on first launch. Needs a renderer.
featureFlagsFeatureFlagOptions()maxWaitMs (2,000 ms) and defaults for flag reads. See Defaults and updates.
analyticsConsentAnalyticsConsent.GRANTEDConsent until your app calls setAnalyticsConsent. See Analytics consent.
automaticLifecycleEventstrueRecords $app_* and $sign_out events. See Automatic events.
screenTrackingScreenTrackingOptions()Automatic $screen events. See Track screens.
installAttributiontrueCredits installs to ad campaigns. See Credit installs.
metaAppIdnullAlso asks Meta's apps about the install. See Meta app-install ads.
onDiagnosticnullReceives problems the SDK handled itself. See Diagnostics.
runInSecondaryProcessfalseRuns the SDK outside the main process.

Disabled clients

With enabled = false, the client makes no requests, opens no billing connection, runs no timers, and leaves its stored data untouched. Methods return empty values: getProducts() and getFeatureFlags() an empty list, getCurrentPerson() and resolvePaywall() null, and flush() and shutdown() nothing sent. purchase throws CONFIGURATION_MISSING, and presentFlow returns FLOW_DISABLED.

Methods

Methods that can wait are suspending functions. They never read storage or post work on the calling thread.

MethodReturnsGuide
initialize()—Create the client
getProducts()List<VoidhashProduct>Load products
purchase(activity, product, offerId)VoidhashTransactionStart a purchase
restorePurchases()—Restore purchases
reportTransaction(purchase, isRestore)—Observer mode
syncPurchases()—Recover with a scan
setReadOnly(readOnly), isReadOnly—Observer mode
getCurrentPerson(forceFetch), getCurrentPersonState()VoidhashPerson?Check access
identify(externalUserId, email, name), identifyWithStatus(...)VoidhashPerson?, PersonWriteResultIdentify users
setPersonAttributes(map), setPersonAttributesWithStatus(map)—, PersonWriteResultSet person attributes
signOut(), reset()—Sign out
getDistinctId()StringRead the distinct ID
presentFlow(activity, placement), dismissFlow()FlowResultPaywalls
resolvePaywall(location), resolvePaywallState(location)ResolvedPaywall?Caching and offline
getFeatureFlags(keys), getFeatureFlagsState(keys)List<FeatureFlag>Feature flags
isFeatureEnabled(key), featureFlagsBoolean, StateFlowDefaults and updates
capture(name, properties), screen(name, properties)—Capture analytics
trackPushOpened(extras)—Report opened notifications
setAnalyticsConsent(consent), analyticsConsent—Analytics consent
setAdDataSharing(granted)PersonWriteResultShare purchases with ad platforms
sessionIdStringSessions and delivery
flush()FlushStatusSessions and delivery
shutdown()FlushStatusShutdown

fetchSchema, fetchPerson, identifyPerson, setPersonTraits, evaluateFeatureFlags, syncStoreTransaction, syncStoreTransactionWithStatus, injectInternalSchema and recordDevelopmentPurchase exist for hosts that embed the client as their transport. They take the distinct ID on every call and skip the cache and identity the app-facing methods manage. Don't call them from an app; use identify, setPersonAttributes, getFeatureFlags and reportTransaction instead.

Caching

Reads answer from the device cache and refresh in the background. A stale read waits at most 500 ms for a refresh. Cached values are never discarded for age; the …State() variants return them with isStale and isExpired.

DataFresh forKept forWait with nothing cached
Person5 minutes2 days10 seconds
Feature flags5 minutesUntil replacedmaxWaitMs, 2 seconds
Paywall per location1 hour7 days10 seconds

Events, purchases and attribute writes are stored on disk and retried until delivered. After 5 failures in a row the SDK pauses requests and serves the cache until a retry succeeds.

Shutdown

Call shutdown() only when the process is going away for good, not when the app goes to the background:

voidhash.shutdown()

It flushes analytics for at most 2 seconds, ends the Google Play connection and stops the SDK's timers. Unsent events stay on the device for the next client. Afterwards Voidhash.shared is null, and the identity, attribute and store methods throw CLIENT_SHUT_DOWN.

Next steps

  • Kotlin SDK.
  • Display a paywall.
  • Errors.

Something wrong or missing on this page? Tell us by email or on Discord.

PreviousDevelopment modeNextErrors

On this page

Client optionsDisabled clientsMethodsCachingShutdownNext steps