Mobile Apps

Collect the encrypted device payload with the native SDK and forward it to your backend to register the login event with SmartID.

SDK Installation

Before integrating, install the SDK in Getting Started → Install the SDK →

GetRawData

Collects device fingerprint data asynchronously and returns it encoded. Call this just before the user submits the login form.

Kotlin
SmartId
    .getInstance()
    .GetRawData(getApplicationContext(), "https://your-backend.com")
    .onSuccess { time, response ->
        // response: encoded device payload
        // forward to your backend alongside user credentials
    }
    .onFailure { time, message, errorCode ->
        // still submit the login — send data as empty string
    }
    .start()
Swift
SID.shared.startLocation()

SID.shared
    .getRawData("https://your-backend.com")
    .onSuccess(success: { time, encodedData in
        // encodedData: encoded device payload
        // forward to your backend alongside user credentials
    })
    .onFailure(failure: { time, message, errorCode in
        // still submit the login — send data as empty string
    })
    .start()
Dart
// Just before form submission
SmartID.getRawData(
    applicationBackendDomain: 'https://your-backend.com',
)
.onSuccess((time, response) {
    // response: encoded device payload
    // forward to your backend alongside user credentials
})
.onFailure((time, message, errorCode) {
    // still submit the login — send data as empty string
})
.start()
TypeScript
import { SmartID } from 'capacitor-smartid';

// iOS only — initialize GPS sensor
await SmartID.startLocation();

try {
    const result = await SmartID.getRawData({
        backendDomain: 'https://your-backend.com'
    });
    // result.data: encoded device payload
    // forward to your backend alongside user credentials
} catch (error) {
    // still submit the login — send data as empty string
}

Method parameters

Parameter Platform Type Description
context Android Context Application context. Required.
applicationBackendDomain (backendDomain on Capacitor) All String Your backend URL. Optional. Used for SSL pinning and pharming detection.

Callback parameters

Parameter Callback Type Description
time Success / Failure Long Execution duration in milliseconds
response Success String Encrypted device payload. Send as-is to the data field of the API.
message Failure String Error description
errorCode Failure Int Error code
Important — failure callback

If the SDK returns a Failure callback, you must still send the login request to your backend, but with an empty data field.

Complete login flow

The SDK runs on the client. Only your backend calls the SmartID API.

1

App calls GetRawData

Android/iOS/Flutter: in the onSuccess callback, the response parameter contains the encrypted payload. Capacitor: the result is in result.data from the try block. Hold it until the user submits the form.

2

App sends credentials + payload to your backend

Include the response value alongside username and password in your request to your own server. If the SDK failed, use an empty string.

3

Your backend calls the SmartID API

Your server POSTs the login event to SmartID with the user attributes and encrypted payload.

POST /api/v5/analytics/app/login
cURL
curl -X POST https://<api-url>/api/v5/analytics/app/login \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer <license>" \\
  -d '{
    "channelId": 2,
    "user": "jlopez",
    "session": "445613456fa",
    "publicIp": "20.201.64.54",
    "data": "<response from GetRawData, empty string on failure>"
  }'
Field Type Required Description
channelIdintegerRequiredYour SmartID channel identifier
userstringRequiredUsername or unique user identifier
sessionstringOptionalYour application session token
publicIpstringRequiredUser's public IP address
datastringRequiredEncrypted payload from GetRawData. Empty string if SDK failed.
4

SmartID returns 200 OK

SmartID logs the event and responds with 200 OK. Proceed with your normal login logic.

Logout

When the user logs out, notify SmartID from your backend. No SDK call is needed from the client.

POST /api/v5/analytics/app/logout
cURL
curl -X POST https://<api-url>/api/v5/analytics/app/logout \\
  -H "Content-Type: application/json" \\
  -H "Authorization: Bearer <license>" \\
  -d '{
    "channelId": 2,
    "user": "jlopez",
    "session": "445613456fa"
  }'
Optional fields on logout

publicIp and data are optional on logout. channelId, user, and session are sufficient to close the event.