Skip to main content

Clickthrough — Mobile Integration (iOS / Android)

SpotDraft provides native, headless utility libraries for iOS and Android. Each library manages backend communication, state, and event delivery — you supply only the UI and a stable user_identifier.

Main Guide — prerequisites, shared events, consent-status semantics, and troubleshooting are covered in Clickthrough SDK.


Choose Your Platform

PlatformLanguageRepository
iOSSwift 5.7+ / Xcode 14+spotdraft-clickthrough-utils-iOS
AndroidKotlin 1.8+ / Jetpack Composespotdraft-clickthrough-utils-android-kotlin
AndroidJava 11+ / View-based UIspotdraft-clickthrough-utils-android-java

iOS (Swift)

Requirements: iOS 15+, Xcode 14+, Swift 5.7+

1 — Add the Utility

  1. Download SpotDraftClickwrap.zip from the iOS releases page.
  2. Drag the unzipped SpotDraftClickwrap folder into your Xcode project.
  3. In the import dialog select Copy items if needed and Create groups, and add files to your main app target.

2 — Initialise Once at App Launch

// In your App's init() or AppDelegate
import SpotDraftClickwrap

SpotDraftManager.initialize(
config: ClickwrapConfig(
clickwrapId: "YOUR_CLICKWRAP_ID", // from SpotDraft console
baseURL: "YOUR_BASE_URL", // from SpotDraft console
domain: "your-app-bundle-id" // optional, used for allowlist matching
)
)

3 — Implement ClickwrapListener

class ConsentViewModel: ObservableObject, ClickwrapListener {

func loadAgreements() {
SpotDraftManager.shared.setClickwrapListener(self)
SpotDraftManager.shared.loadClickwrap()
}

// MARK: - ClickwrapListener

func onReady(clickwrap: Clickwrap) {
// Render clickwrap.policies as checkboxes in your UI
}

func onAcceptanceChange(policyId: String, isAccepted: Bool) {
// Update individual policy checkbox state
}

func onAllAcceptedChange(allAccepted: Bool) {
// Enable / disable your submit button
}

func onAgreementViewed(agreementId: String) {
// Optional: track that the user viewed a policy document
}

func onSubmitSuccessful(submissionPublicId: String) {
// Navigate to the next screen
}

func onPolicyReAcceptanceStatus(result: ReAcceptanceResult) {
// If result.isReAcceptanceRequired == true, re-show the consent flow
}

func onError(error: ClickwrapError) {
// Display an error message
}
}

4 — Submit Acceptance

SpotDraftManager.shared.submitAcceptance(userIdentifier: "johndoe@example.com")

5 — Check Re-Acceptance (Returning Users)

SpotDraftManager.shared.checkForPolicyReAcceptance(userIdentifier: "johndoe@example.com")
// Result delivered via onPolicyReAcceptanceStatus

iOS Event Reference

CallbackWhen it fires
onReady(clickwrap:)Clickwrap data loaded successfully
onAcceptanceChange(policyId:isAccepted:)A single policy checkbox toggled
onAllAcceptedChange(allAccepted:)Aggregate acceptance changed
onAgreementViewed(agreementId:)A policy document was viewed
onSubmitSuccessful(submissionPublicId:)Consent recorded successfully
onPolicyReAcceptanceStatus(result:)Re-acceptance check completed
onError(error:)Any error in the utility

For full iOS source code and a working demo app, see the iOS repository.


Android — Kotlin / Jetpack Compose

Requirements: Android SDK 21+, Android Studio Flamingo+, Kotlin 1.8+, Jetpack Compose 1.4+

1 — Add the Utility Module

  1. Download spotdraftclickwrap.zip from the Kotlin releases page.

  2. Unzip and copy the spotdraftclickwrap folder into the root of your Android Studio project.

  3. Register the module in settings.gradle.kts:

    include(":app", ":spotdraftclickwrap")
  4. Add the dependency in app/build.gradle.kts:

    dependencies {
    implementation(project(":spotdraftclickwrap"))
    }
  5. Sync the project.

2 — Initialise in Application.onCreate()

import com.app.android.clickwrap.config.ClickwrapConfig
import com.app.android.clickwrap.core.SpotDraftManager

class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
SpotDraftManager.initialize(
this,
ClickwrapConfig(
clickwrapId = "YOUR_CLICKWRAP_ID",
baseURL = "YOUR_BASE_URL",
domain = "your-app-domain.com"
)
)
}
}

3 — Implement ClickwrapListener in Your ViewModel

import com.app.android.clickwrap.core.ClickwrapListener
import com.app.android.clickwrap.domain.model.Clickwrap
import com.app.android.clickwrap.domain.model.ReAcceptanceResult
import com.app.android.clickwrap.helper.errors.ClickwrapError

class ConsentViewModel : ViewModel(), ClickwrapListener {

fun load() {
SpotDraftManager.shared.setClickwrapListener(this)
SpotDraftManager.shared.loadClickwrap()
}

override fun onReady(clickwrap: Clickwrap) { /* render policies */ }
override fun onAcceptanceChange(policyId: String, isAccepted: Boolean) { /* update checkbox */ }
override fun onAllAcceptedChange(allAccepted: Boolean) { /* enable submit button */ }
override fun onAgreementViewed(agreementId: String) { }
override fun onSubmitSuccessful(submissionPublicId: String) { /* navigate forward */ }
override fun onPolicyReAcceptanceStatus(result: ReAcceptanceResult) { /* handle re-acceptance */ }
override fun onError(error: ClickwrapError) { /* show error */ }
}

4 — Submit and Re-Check

// Submit on first acceptance
SpotDraftManager.shared.submitAcceptance(userIdentifier = "johndoe@example.com")

// On login / return — check whether re-acceptance is required
SpotDraftManager.shared.checkForPolicyReAcceptance(userIdentifier = "johndoe@example.com")

For full Kotlin source and a demo app, see the Android Kotlin repository.


Android — Java / View-based UI

Requirements: Android SDK 21+, Java 11+, Gradle 8.1+

1 — Add the Utility Module

  1. Download spotdraftclickwrap.zip from the Java releases page.

  2. Unzip and place the spotdraftclickwrap folder in your project root.

  3. Ensure settings.gradle.kts includes:

    include(":app", ":spotdraftclickwrap")
  4. Ensure app/build.gradle.kts declares:

    implementation(project(":spotdraftclickwrap"))

2 — Initialise in Application.onCreate()

import com.app.android.clickwrap.config.ClickwrapConfig;
import com.app.android.clickwrap.core.SpotDraftManager;

public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ClickwrapConfig config = new ClickwrapConfig(
"YOUR_CLICKWRAP_ID",
"YOUR_BASE_URL",
"your-app-domain.com"
);
SpotDraftManager.initialize(this, config);
}
}

3 — Implement ClickwrapListener

Implement ClickwrapListener in your Activity or ViewModel and call the same setClickwrapListener, loadClickwrap, submitAcceptance, and checkForPolicyReAcceptance methods as in the Kotlin guide above (method signatures are Java-friendly).

For full Java source and a demo app, see the Android Java repository.


Shared Mobile Events

All three mobile utilities fire equivalent lifecycle events. See Event Handling for the shared event table and Common Setup Issue for troubleshooting.


See Also