PactDOCS

Integrate / Android

Native Android SDK

Use one Kotlin consent client for managed Jetpack Compose and fully headless product experiences.
01

Install from pinned source

settings.gradle.kts
kotlin
includeBuild("Vendor/pact/sdks/android") {
    dependencySubstitution {
        substitute(module("com.pact:pact-consent"))
            .using(project(":pact-consent"))
    }
}
app/build.gradle.kts
kotlin
dependencies {
    implementation("com.pact:pact-consent:0.1.0")
}

The library requires Android API 23 or newer and Java 17.

02

Create the native client

ConsentModule.kt
kotlin
import com.pact.consent.*

val consent = PactConsentClient(
    context = applicationContext,
    configuration = PactConfiguration(
        baseUrl = "https://consent.example.com",
        tenantId = "acme",
        consentScopeId = "customer-account",
        policyVersion = "policy-2026-08",
        region = "EU",
        binding = PactDeploymentBinding.android("com.example.app"),
        purposes = listOf(
            PactPurposeDefinition(PactPurpose.ESSENTIAL, "Essential", "Required", true),
            PactPurposeDefinition(PactPurpose.ANALYTICS, "Measurement", "Understand product use"),
            PactPurposeDefinition(PactPurpose.MARKETING, "Advertising", "Relevant advertising"),
        ),
    ),
)
03

Use managed Compose

PrivacySettings.kt
kotlin
PactPrivacyButton(client = consent) { dismiss ->
    ModalBottomSheet(onDismissRequest = dismiss) {
        PactConsentSheet(client = consent, onDismiss = dismiss)
    }
}
04

Use the headless API

PrivacyViewModel.kt
kotlin
consent.deny(setOf(PactPurpose.MARKETING))
consent.save(mapOf(
    PactPurpose.ANALYTICS to true,
    PactPurpose.MARKETING to false,
))

if (consent.isAllowed(PactPurpose.ANALYTICS)) startMeasurement()
NextConfigure cross-device consent