Native location and device risk signals

Kade Android Core SDK

Integrate encrypted geofence checks, continuous verification, persisted fingerprints, and native device signals directly in a Kotlin application.

1.1.0 current version minSdk 23 compileSdk 34 JVM 17 No React Native in Core

Overview

KadeClient.getInstance(context) is the high-level native entry point. It owns configuration, encryption, pings, continuous checks, and fingerprint submission while retaining only the application context.

Native Core

The io.kade.sdk.core module is a Kotlin Android library with React Native dependencies explicitly excluded.

One process-wide client

Obtain the singleton with an Android Context, start it before calling ping or training methods, and stop ongoing work when the protected flow ends.

Every call has a suspend version and a callback version. Native Core exposes evaluateEmail(EvaluateEmailOptions) for fire-and-forget registration email evaluation. The server always answers with an empty response; the verdict is visible only to operators. It does not expose network-based location estimation APIs. React Native bridge methods are intentionally excluded from this guide.

Migration and compatibility

Version 1.1.0 completes the native Kade rename. Use KadeClient, KadeCore, KadeConfig, KadeErrorCodes, and KadeSdkException.

Legacy public aliases have been removed. Android classes live in the io.kade.sdk.core package. Persisted storage keys keep their original com.videntrix.geofence prefix so existing installs keep their identifiers, and the React Native bridge is now named KadeSdk.

Availability

The Android Core SDK is not currently distributed as a standalone public Maven artifact. There are no public Maven coordinates or repository installation commands to use.

Contact Kade for access. Kade will provide the approved source or integration package, dependency setup, credentials, and packaging instructions for your application.

The current source module is configured with minSdk 23, compileSdk 34, targetSdk 34, Java 17, and Kotlin JVM target 17. These facts describe the source module, not a public release.

Integration

After Kade supplies the native package, add it according to the delivery-specific instructions. Do not invent a remote dependency coordinate or include the React Native bridge in a native-only app.

Host build requirements

android {
  compileSdk 34

  defaultConfig {
    minSdk 23
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
  }

  kotlinOptions {
    jvmTarget = '17'
  }
}

When Kade supplies Core as source, its module declares coroutines, AndroidX Core, Security Crypto, Lifecycle Process, Google Play services Location and Block Store, Play Integrity, and OkHttp dependencies. Follow the supplied packaging instructions to determine whether your host must declare any of them directly.

Quick start

Obtain the singleton, start it, and issue a ping only after start succeeds. From a coroutine, use the suspend versions; failures throw a KadeSdkException.

import io.kade.sdk.core.KadeClient
import io.kade.sdk.core.KadeConfig
import io.kade.sdk.core.KadeSdkException
import io.kade.sdk.core.PingOptions

val client = KadeClient.getInstance(applicationContext)

lifecycleScope.launch {
    try {
        client.start(KadeConfig(apiToken = "your-api-token", regionId = 123))
        val response = client.ping(
            PingOptions(userId = "player-123", source = "login", email = "player@example.com"),
        )
        if (response.blocked == true) {
            println("Blocked: ${response.code ?: "unknown"}")
        } else {
            println("Inside: ${response.inside}, area: ${response.area?.name ?: "none"}")
        }
    } catch (error: KadeSdkException) {
        // error.code: a location code or GEOFENCE_INIT / GEOFENCE_PING;
        // error.httpStatus when the server answered with an error status.
        println("Kade failed: ${error.code} ${error.httpStatus ?: ""} ${error.message}")
    }
}

The same flow with callbacks:

val client = KadeClient.getInstance(applicationContext)
val config = KadeConfig(
    apiToken = "your-api-token",
    regionId = 123,
)

client.start(config) { startResult ->
    startResult.fold(
        onSuccess = {
            client.ping(
                options = PingOptions(
                    userId = "player-123",
                    source = "login",
                    email = "player@example.com",
                ),
            ) { pingResult ->
                pingResult.fold(
                    onSuccess = { response ->
                        if (response.blocked == true) {
                            println("Blocked: ${response.code ?: "unknown"}")
                        } else {
                            println("Inside: ${response.inside}")
                            println("Area: ${response.area?.name ?: "none"}")
                        }
                    },
                    onFailure = { error ->
                        println("Kade ping failed: $error")
                    },
                )
            }
        },
        onFailure = { error ->
            println("Kade startup failed: $error")
        },
    )
}
start initializes on the SDK's background coroutine scope, hydrates persisted client identity, derives the encryption key, and then invokes (Result<Unit>) -> Unit (or returns, for the suspend version). Do not treat the client as ready before it succeeded. Callbacks arrive on a background thread; a failure found up front (not started yet) calls back at once on the calling thread. The suspend versions resume in the caller's context.

Permissions

Core declares network and foreground location permissions. Android still requires the host app to request dangerous location permissions at runtime.

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>
private val core by lazy { KadeCore.getInstance(this) }

private val locationPermission =
    registerForActivityResult(
        ActivityResultContracts.RequestMultiplePermissions(),
    ) {
        when (core.getLocationPermissionStatus(this)) {
            PermissionStatus.GRANTED -> beginVerification()
            else -> showPreciseLocationRequired()
        }
    }

fun requestKadeLocation() {
    // Lets getLocationPermissionStatus tell "never asked" from "denied" later.
    core.markLocationPermissionRequested()
    locationPermission.launch(KadeCore.LOCATION_PERMISSIONS)
}
APIBehavior
KadeCore.LOCATION_PERMISSIONSWhat to request: fine (what pings need) and coarse. Android 12+ lets the user pick approximate.
markLocationPermissionRequested()Call right before showing the system dialog. Android has no "not determined" state; this flag lets the status tell "never asked" from "denied".
getLocationPermissionStatus(activity: Activity? = null)GRANTED with fine (precise) location, which a geofence check needs; NOT_DETERMINED before the first request; DENIED otherwise, coarse-only included. Pass the current Activity when there is one: it recognises a denial even when your app asked without the flag.
Core reports missing location permission, precise location being required, and disabled location services as distinct error codes (see Errors). Request both permissions, check the status, and handle disabled services before starting continuous checks.

If your Kade policy permits a server-side check without device location, set skipLocation = true in PingOptions. Confirm that policy with Kade; this is not a network-estimate API.

Core API

These signatures are from the native Kotlin Core module, not its React Native bridge.

KadeClient.getInstance(context: Context): KadeClient Returns the process-wide singleton and stores the application context.
suspend start(config: KadeConfig)
start(config: KadeConfig, callback: (Result<Unit>) -> Unit)
Configures Core, hydrates identity, derives the encryption key, and prepares the ping client.
suspend ping(options: PingOptions = PingOptions()): PingResponse
ping(options: PingOptions, callback: (Result<PingResponse>) -> Unit)
Sends one geofence check. It fails with GEOFENCE_PING when the client has not been started.
startContinuousPing(options: PingOptions) Starts one continuous controller. Never throws: when location is off or not permitted (and skipLocation is false) it reports that once through onPingError and doesn't start, so a later call can start it.
stopContinuousPing() Stops and releases the continuous controller.
currentFingerprint(): FingerprintResult Returns the local fingerprint containing visitorId.
suspend sendFingerprintForTraining(userId: String): JSONObject
sendFingerprintForTraining(userId: String, callback: (Result<JSONObject>) -> Unit)
Sends an encrypted fingerprint and static markers to the configured server and returns its raw JSON object.
suspend evaluateEmail(options: EvaluateEmailOptions)
evaluateEmail(options: EvaluateEmailOptions, callback: (Result<Unit>) -> Unit)
Registration email evaluation. EvaluateEmailOptions has the JavaScript SDKs' option names: email (required), firstName, lastName, userId, dob, gender, occupation, phone, postalCode, addressLine, referrerPlayerId, referralCode, trafficSource, platform, metadata (your own key/value pairs such as ad click IDs and campaign tags: strings, numbers and booleans; anything else is dropped; use facebookClickId, googleClickId, redtrackClickId, microsoftClickId, tiktokClickId and utmCampaign for the identifiers Kade recognises) and includeLocation (default true: attach the last known fix only when the permission is already held; never prompts).
suspend addressLocation(): AddressSessionLocation?
addressLocation(callback: (AddressSessionLocation?) -> Unit)
The newest fix the device already holds, or null. Never prompts and never turns on GPS.
suspend addressPost(url: String, bodyJson: String): AddressResponse
addressPost(url: String, bodyJson: String, callback: (status: Int, body: String?) -> Unit)
One Address API call in the same envelope and signature as a ping. Status 0 means no response came. Never throws.
KadeCore.sdkVersion: String The SDK version.
destroy() Stops continuous work, destroys Core resources, resets active markers, and clears client configuration and key material.

Fingerprint submission

val fingerprint = client.currentFingerprint()
println("Visitor ID: ${fingerprint.visitorId}")

client.sendFingerprintForTraining("player-123") { result ->
    result.fold(
        onSuccess = { json -> println("Server response: $json") },
        onFailure = { error -> println("Submission failed: $error") },
    )
}

Results as JSON

PingResponse, AddressSessionLocation, GeoLocation, DeviceInfo, FingerprintResult, MobileMarkers and the detector results implement KadeJsonRepresentable: toJson() returns a new JSONObject with the same keys the React Native SDK hands JavaScript (absent when null).

val response = client.ping(PingOptions(userId = "player-123"))
log(response.toJson().toString(2))
// {"inside":true,"status":200,"interval":10000,"distanceToBorder":5120.4,"regionId":123, ...}

Configuration

KadeConfig

FieldType and defaultBehavior
apiTokenString, requiredWorkspace API token.
serverUrlString, https://api.kade.ioAPI base URL.
regionIdInt?, nullDefault region; ping-level value overrides it.
signingSecretString?, nullEnables request signing when non-empty.
locationStrategyLocationStrategy, RACELocation retrieval strategy.
locationMaxAgeMsLong, 120,000Preferred cached-fix age. This is the floor of a dynamic reuse window.
locationMaxAgeCapMsLong, 600,000Upper bound for the dynamic cached-fix reuse window.
locationMaxStalenessRadiusDouble, 100.0Staleness radius used by location selection.
locationAccuracyLocationAccuracy, HIGHHIGH, BALANCED, or LOW.
debugBoolean, falseEnables verbose SDK logging.

PingOptions

val options = PingOptions(
    userId = "player-123",
    silent = false,
    skipLocation = false,
    source = "deposit",
    regionId = 123,
    email = "player@example.com",
    firstName = "Player",
    lastName = "One",
)

Every option has a default. source is a free-form flow tag, regionId overrides configuration for that ping, and identity fields are associated with the server-side client record.

Lifecycle and continuous checks

Register handlers before starting continuous checks and stop them when the protected flow ends. Core includes AndroidX process lifecycle support for its continuous controller.

client.onPingResponse = { response ->
    runOnUiThread {
        updateAccessState(response)
    }
}

client.onPingError = { error: KadeSdkException ->
    runOnUiThread {
        // A location code (location off or not permitted: the loop stops),
        // or GEOFENCE_PING_ERROR for any other failure.
        handleLocationSetupError(error.code)
    }
}

client.startContinuousPing(
    PingOptions(
        userId = "player-123",
        source = "session",
    ),
)

// When the verified flow ends:
client.stopContinuousPing()

// When disposing the entire integration:
client.destroy()

Response handling

Branch on blocked first, tolerate nullable fields, and keep failed Result values separate from server verdicts.

fun handle(response: PingResponse) {
    if (response.blocked == true) {
        denyAccess(
            code = response.code,
            message = response.message,
        )
        return
    }

    if (response.inside) {
        allowAccess(response.area?.name)
    } else {
        showOutsideRegion(response.distanceToBorder)
    }

    if (response.requestLocation == true) {
        // Revisit permission and location services before the next check.
    }
}
FieldTypeMeaning
insideBooleanWhether the server resolved the client inside the relevant geofence.
statusIntServer response status value.
message, codeString?Optional response detail and machine-readable code.
intervalIntServer-provided interval; model default is 10,000.
distanceToBorderDoubleDistance value returned by the server.
regionIdInt?Resolved region when present.
areaPingArea?Matched area with id and name.
blockedBoolean?Explicit block decision when supplied.
requestLocationBoolean?Reserved: the server does not send it yet (asks the client to obtain location).
deviceTrustTtlInt?Reserved: the server does not send it yet (device-trust lifetime in ms).

Location setup errors

fun handleLocationSetupError(code: String) {
    when (code) {
        KadeErrorCodes.LOCATION_PERMISSION_MISSING ->
            requestLocationPermission()
        KadeErrorCodes.LOCATION_PERMISSION_PRECISE_REQUIRED ->
            explainPreciseLocation()
        KadeErrorCodes.LOCATION_SERVICES_DISABLED ->
            promptToEnableLocationServices()
        else ->
            showVerificationUnavailable()
    }
}

Errors

Every failure from KadeClient, as a callback's failed Result, a thrown exception from a suspend version, or through onPingError, is a KadeSdkException. It has already been reported to Kade; you don't need to report it again.

PropertyTypeMeaning
codeStringStable code to match on (below); the same strings the React Native SDK rejects with.
httpStatusInt?The HTTP status when the server answered with an error status, else null.
messageString?What went wrong, for logs. Not stable.
causeThrowable?The exception Core caught, when there is one.
KadeErrorCodesCodeWhen
LOCATION_PERMISSION_MISSINGLOCATION_PERMISSION_MISSINGNo location permission.
LOCATION_PERMISSION_PRECISE_REQUIREDLOCATION_PERMISSION_PRECISE_REQUIREDOnly approximate location granted.
LOCATION_SERVICES_DISABLEDLOCATION_SERVICES_DISABLEDLocation turned off on the device.
STARTGEOFENCE_INITstart failed.
PINGGEOFENCE_PINGping failed: not started, no response, or an HTTP error.
CONTINUOUS_PINGGEOFENCE_PING_ERRORA continuous-ping failure other than location.
FINGERPRINTGEOFENCE_FINGERPRINTsendFingerprintForTraining failed.
EVALUATE_EMAILGEOFENCE_EVALUATE_EMAILevaluateEmail failed, or email was empty.

A blocked ping is not an error: it is a PingResponse with blocked == true and a code.

Get the native Android package

Talk to Kade for SDK access, approved packaging, credentials, and integration guidance for your application.

Contact Kade