Native location and device risk signals

Kade iOS Core SDK

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

iOS 13.0+ deployment target 1.1.0 current version Swift 5.7 No React in Core Singleton client lifecycle

Overview

KadeClient.shared is the high-level native entry point. It owns configuration, encryption, pings, continuous checks, and fingerprint submission. KadeCore.shared exposes lower-level permissions, location, device, and marker collection.

Native Core

The Core source is platform-native Swift and does not import React. The React Native bridge is a separate layer and is not part of this API.

One process-wide client

Use the shared client, start it before calling ping or training methods, and destroy it when the integration is no longer needed.

Every call has an async version and a completion-handler version. Native Core exposes evaluateEmail(_:) with 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.

Migration and compatibility

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

The podspec, pod, and Swift module are named KadeSdk. Legacy public aliases have been removed. Persisted storage keys, encryption, payloads, routes, and wire error-code strings remain unchanged.

Availability

The iOS Core SDK is not currently distributed as a standalone public CocoaPods artifact. There is no public pod installation command to use.

Contact Kade for access. Kade will provide the approved source or integration package and the packaging instructions for your application. The repository podspec defines a React-free Core subspec, but that does not constitute a public release.

The source configuration sets an iOS 13.0 minimum, Swift 5.7, and links Foundation, CoreLocation, CoreMotion, SystemConfiguration, Network, Security, and DeviceCheck.

Integration

After Kade supplies the native package, add it to the application target using the delivery-specific instructions. Do not add the React Native bridge to a native-only target.

Application requirements

Build your application target to verify the delivered package:

xcodebuild \
  -workspace YourApp.xcworkspace \
  -scheme YourApp \
  -sdk iphonesimulator \
  build
Repository packaging uses the KadeSdk pod and module name. Follow the package-specific instructions you receive.

Quick start

Start the shared client, then issue a ping only after configuration succeeds. With Swift concurrency, use the async versions; failures throw a KadeError.

import KadeSdk

let client = KadeClient.shared

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

The same flow with completion handlers:

let client = KadeClient.shared
let config = KadeConfig(
    apiToken: "your-api-token",
    regionId: 123
)

client.start(config: config) { result in
    switch result {
    case .success:
        let options = PingOptions(
            userId: "player-123",
            source: "login",
            email: "player@example.com"
        )

        client.ping(options: options) { pingResult in
            switch pingResult {
            case .success(let response):
                if response.blocked == true {
                    print("Blocked:", response.code ?? "unknown")
                } else {
                    print("Inside:", response.inside)
                    print("Area:", response.area?.name ?? "none")
                }
            case .failure(let error):
                print("Kade ping failed:", error)
            }
        }
    case .failure(let error):
        print("Kade startup failed:", error)
    }
}
start(config:completion:) derives the encryption key on a background queue and invokes its completion with a Result<Void, KadeError>. Do not assume the client is ready immediately after calling start. Completions arrive on a background queue; a failure found up front (not started yet) completes at once on the calling thread. The async versions resume on the caller's executor (the main actor for main-actor code).

Location permissions

Add a user-facing location purpose string to the host application's Info.plist, then use KadeCore to inspect and request authorization.

<key>NSLocationWhenInUseUsageDescription</key>
<string>Your location is used to verify availability in your region.</string>
let core = KadeCore.shared

switch core.getLocationPermissionStatus() {
case .granted:
    beginVerification()
case .notDetermined:
    Task { @MainActor in
        // Or the completion-handler version: requestLocationPermission { status in … }
        if await core.requestLocationPermission() == .granted {
            beginVerification()
        } else {
            showLocationUnavailable()
        }
    }
case .denied, .restricted:
    showLocationUnavailable()
}

The native permission states are granted, denied, restricted, and notDetermined; reduced (approximate) accuracy counts as granted. Android reports the same values with the same meaning. If your policy permits a server-side check without device location, set skipLocation: true on PingOptions; confirm that policy with Kade.

Core reports missing permission, insufficient precision, disabled location services, timeouts, and unavailable location as distinct error codes (see Errors). Explain the request before prompting and handle every non-granted state.

Core API

These are native Swift signatures from the Core layer, not React Native bridge methods.

KadeClient

KadeClient.shared Returns the process-wide client instance. Its initializer is private.
start(config: KadeConfig) async throws
start(config: KadeConfig, completion: @escaping (Result<Void, KadeError>) -> Void)
Configures Core, derives the encryption key, and prepares the ping client.
ping(options: PingOptions = PingOptions()) async throws -> PingResponse
ping(options: PingOptions, completion: @escaping (Result<PingResponse, KadeError>) -> Void)
Sends one geofence check. It fails with GEOFENCE_PING if startup has not completed.
startContinuousPing(options: PingOptions) Starts one continuous controller. Responses and errors are delivered through onPingResponse and onPingError.
stopContinuousPing() Stops and releases the continuous controller.
currentFingerprint() -> FingerprintResult Returns the current local fingerprint, containing visitorId.
sendFingerprintForTraining(userId: String) async throws -> [String: Any]
sendFingerprintForTraining(userId: String, completion: @escaping (Result<[String: Any], KadeError>) -> Void)
Sends the encrypted fingerprint and static markers to the configured server and returns its raw JSON dictionary.
evaluateEmail(_ options: EvaluateEmailOptions) async throws
evaluateEmail(_ options: EvaluateEmailOptions, completion: @escaping (Result<Void, KadeError>) -> Void)
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 cached fix only when the permission is already held; never prompts).
addressLocation() async -> AddressSessionLocation?
addressLocation(completion: @escaping (AddressSessionLocation?) -> Void)
The newest fix the device already holds, or nil. Never prompts and never turns on GPS. Completes on a background queue.
addressPost(url: String, bodyJson: String) async -> AddressResponse
addressPost(url: String, bodyJson: String, completion: @escaping (Int, String?) -> Void)
One Address API call in the same envelope and signature as a ping. Status 0 means no response came. Never throws.
destroy() Stops continuous work, destroys Core resources, resets active markers, and clears client configuration and key material.

Selected KadeCore methods

let core = KadeCore.shared

let status = core.getLocationPermissionStatus()
let device = core.getDeviceInfo()
let jailbreak = core.getJailbreak()
let developerMode = core.getDeveloperMode()
let mockLocation = core.getMockLocation()
let locationSource = core.getLocationSource()
let vpn = core.getVpn()
let battery = core.getBattery()

let fix = try await core.getCurrentLocation(
    accuracy: .high,
    timeoutMs: 10_000,
    maxAgeMs: 120_000
)
let markers = await core.getMobileMarkers(options: MobileMarkersOptions(includeSensors: false))
print(KadeCore.sdkVersion)

Core also exposes sensor collection, integrity attestation, persisted fingerprint ID accessors, and explicit location watcher controls, each with an async and a completion-handler version where it is asynchronous. Most integrations should prefer KadeClient for policy checks.

Results as JSON

PingResponse, AddressSessionLocation, GeoLocation, DeviceInfo, FingerprintResult, MobileMarkers and the detector results conform to KadeJSONRepresentable: asDictionary() returns the same keys the React Native SDK hands JavaScript (absent when nil), and jsonString(pretty:) the JSON text.

let response = try await client.ping(options: PingOptions(userId: "player-123"))
print(response.jsonString(pretty: true))
// { "distanceToBorder" : 5120.4, "inside" : true, "interval" : 10000, "regionId" : 123, … }

Configuration

KadeConfig

FieldType and defaultBehavior
apiTokenString, requiredWorkspace API token.
serverUrlString, https://api.kade.ioAPI base URL.
regionIdInt?, nilDefault region; ping-level value overrides it.
signingSecretString?, nilEnables request signing when non-empty.
locationStrategyLocationStrategy, .raceLocation retrieval strategy.
locationMaxAgeMsInt, 120,000Preferred cached-fix age. This is the floor of a dynamic reuse window.
locationMaxAgeCapMsInt, 600,000Upper bound for the dynamic cached-fix reuse window.
locationMaxStalenessRadiusDouble, 100Staleness radius used by location selection.
locationAccuracyLocationAccuracy, .high.high, .balanced, or .low.
debugBool, falseEnables verbose SDK logging.

PingOptions

let 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, retain no second client instance, and stop checks when the protected flow ends.

let client = KadeClient.shared

client.onPingResponse = { response in
    DispatchQueue.main.async {
        updateAccessState(using: response)
    }
}

client.onPingError = { (error: KadeError) in
    DispatchQueue.main.async {
        // A location code, or GEOFENCE_PING_ERROR for any other failure.
        showVerificationError(code: error.code)
    }
}

client.startContinuousPing(
    options: 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 optional fields, and keep transport failures separate from server verdicts.

func handle(_ response: PingResponse) {
    if response.blocked == true {
        if response.code == KadeErrorCodes.locationPermissionMissing {
            showLocationPermissionHelp()
        }
        denyAccess(
            code: response.code,
            message: response.message
        )
        return
    }

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

    if response.requestLocation == true {
        // Revisit the permission/location flow before the next check.
    }
}
FieldTypeMeaning
insideBoolWhether 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 used by continuous checks; the model default is 10,000.
distanceToBorderDoubleDistance value returned by the server.
regionIdInt?Resolved region when present.
areaPingArea?Matched area with id and name.
blockedBool?Explicit block decision when supplied.
requestLocationBool?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).

Errors

Every failure from KadeClient, in a completion's Result, thrown by an async version, or passed to onPingError, is a KadeError. 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 nil.
messageStringWhat went wrong, for logs. Not stable. Also the error's localizedDescription.
underlyingErrorError?The error Core caught, such as a URLError, when there is one.
KadeErrorCodesCodeWhen
locationPermissionMissingLOCATION_PERMISSION_MISSINGNo location permission.
locationPermissionPreciseRequiredLOCATION_PERMISSION_PRECISE_REQUIREDPrecise location required.
locationServicesDisabledLOCATION_SERVICES_DISABLEDLocation turned off on the device.
locationTimeout, locationUnavailableLOCATION_TIMEOUT, LOCATION_UNAVAILABLENo fix in time, or none available.
startGEOFENCE_INITstart failed.
pingGEOFENCE_PINGping failed: not started, no response, or an HTTP error.
continuousPingGEOFENCE_PING_ERRORA continuous-ping failure other than location.
fingerprintGEOFENCE_FINGERPRINTsendFingerprintForTraining failed.
evaluateEmailGEOFENCE_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 iOS package

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

Contact Kade