--- title: "Darwinium Mobile SDK Setup: Android and iOS" slug: "mobile-sdk-deployment" description: "Install and configure Darwinium mobile SDKs for Android and iOS, collect profiling data, and connect the app to your event integration." updated: 2026-08-11T11:20:03Z published: 2026-08-11T11:20:03Z canonical: "docs.darwinium.com/mobile-sdk-deployment" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.darwinium.com/llms.txt > Use this file to discover all available pages before exploring further. # Mobile SDK Deployment It is suggested to start with [Darwinium Profiling](/v1/docs/darwinium-profiling) for overview of profiling. Darwinium's SDK is designed to fit into your existing implementation without the need to call 3rd party APIs from directly within your app - simply append collected profiling data as a header, `Dwn-Profiling` to an existing request, and have this processed by an edge step infront of an API, or call the API with this data from your backend. ![image.png](https://cdn.document360.io/db6f7316-640d-4099-b5a1-b01b4dbd17fc/Images/Documentation/image%284%29.png?sv=2026-02-06&spr=https&st=2026-11-19T12%3A35%3A27Z&se=2026-11-19T13%3A35%3A27Z&sr=b&sp=r&sig=e9CJZVjcUGnz9UWPI4%2BtCNjzApOeXXYQa1zkhVQnXeI%3D) *Option 1: Add a step to your API endpoint to process SDK profiling data automatically* ![image.png](https://cdn.document360.io/db6f7316-640d-4099-b5a1-b01b4dbd17fc/Images/Documentation/image%283%29.png?sv=2026-02-06&spr=https&st=2026-11-19T12%3A35%3A27Z&se=2026-11-19T13%3A35%3A27Z&sr=b&sp=r&sig=u9SREgY5s8nnJDHa%2B6lSDmjWsQit0Euwu0msgLizQJk%3D) *Option 2: Manually process profiling data using a backend call* ## Initial configuration & Repository Access Darwinium's iOS and Android SDKs are kept up-to-date using modern package management tools (git, artifactory). To access this, you will require an **API Token**. A token can be obtained by going to the [Darwinium Portal](https://portal.darwinium.com) and clicking **Preferences**: ![image.png](https://cdn.document360.io/db6f7316-640d-4099-b5a1-b01b4dbd17fc/Images/Documentation/image.png?sv=2026-02-06&spr=https&st=2026-11-19T12%3A35%3A27Z&se=2026-11-19T13%3A35%3A27Z&sr=b&sp=r&sig=s2vKevqRuYphtVV3vc653oG8FyTChD2UsiZu%2FwwrdRs%3D) Once in the preferences screen, click **SDK Access** and then click **Generate Token** ![image.png](https://cdn.document360.io/db6f7316-640d-4099-b5a1-b01b4dbd17fc/Images/Documentation/image%281%29.png?sv=2026-02-06&spr=https&st=2026-11-19T12%3A35%3A27Z&se=2026-11-19T13%3A35%3A27Z&sr=b&sp=r&sig=hcEVj9%2BHh3sft30CUcndOKASRHgl86WTpwWDttpwezM%3D) This will provide a username (the same as the username used to access Darwinium) and token. Note these down as they will only appear once. ![image.png](https://cdn.document360.io/db6f7316-640d-4099-b5a1-b01b4dbd17fc/Images/Documentation/image%282%29.png?sv=2026-02-06&spr=https&st=2026-11-19T12%3A35%3A27Z&se=2026-11-19T13%3A35%3A27Z&sr=b&sp=r&sig=Tguz4SaQ4d1q9ez0dJjgfw6eTQIu2VPOGzq8d1xfNVQ%3D) ### Setup - Android Darwinium's Android SDK currently works with **API level 23 and above** (Android 6) per [Play Store Guidelines](https://developer.android.com/google/play/requirements/target-sdk). If you require support for older versions of Android, please contact our team on support@darwinium.com [Release Notes SDK](/v1/docs/release-notes-sdk) shows released Darwinium Android SDK versions. This guide assumes your project uses **Gradle** and Kotlin as a language. It will work with Java implementations, although slightly different implementation will be required (beyond the scope of this guide). #### Add Darwinium maven repo to settings Open `settings.gradle` in your project's root, and add the Darwinium maven repo to the `dependencyResolutionManagement` section of the file. An example of this full section is shown below: ``` dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() // Darwinium Maven repository. Variables stored in gradle.properties maven { name = 'DarwiniumMavenRepo' url = "${dwn_maven_url}" credentials { username = "${dwn_maven_user}" password = "${dwn_maven_pwd}" } } } } ``` #### Add credentials to properties Next, add your credentials (username, API token) to `gradle.properties`: ``` dwn_maven_url=https://packages.darwinium.com/artifactory/dwn-maven/ dwn_maven_user= dwn_maven_pwd= ``` #### Add the Darwinium SDK as dependency in build Open `build.gradle` in your project's root, and add Darwinium SDK under `dependencies`: ``` implementation 'com.darwinium:android_sdk:2.4.0' ``` [Release Notes SDK](/v1/docs/release-notes-sdk) shows released Darwinium Android SDK versions #### Add dependencies for additional attribute profiling In app `build.grade`, add following libraries if you want **fine grained location detection** and/or **advertising_id** The libraries are not included as dependencies for Darwinium SDK directly. ``` implementation 'com.google.android.gms:play-services-location:21.0.1' implementation 'com.google.android.gms:play-services-ads-lite:20.3.0' ``` **play-services-location** - Provides high-accuracy, battery-efficient location tracking using the Fused Location Provider API. **play-services-ads-lite** - Enables lightweight AdMob integration for displaying basic ads in Android apps with minimal overhead To collect advertising_id on Huawei Device, you can include Huawei maven repo and add the following dependency ``` maven { url 'https://developer.huawei.com/repo/' content { includeGroup "com.huawei.hms" } } implementation 'com.huawei.hms:ads-identifier:3.4.62.300' ``` #### Proguard if you use Proguard, add the following lines to proguard-rules.pro ``` -keep class com.darwinium.dwn_sdk.DwnProfilingSDK { public *; } -keep class * extends com.google.protobuf.GeneratedMessageLite { *; } ``` #### Add SDK profiling into your APP import the Darwinium SDK using: ``` import com.darwinium.dwn_sdk.DwnProfilingSDK ``` [SDK integration example](https://dahibthxi6hbt.cloudfront.net/dwn-api-docs/android/dwn_sdk/com.darwinium.dwn_sdk/-dwn-profiling-s-d-k/index.html) [Inline Frame Example](https://dahibthxi6hbt.cloudfront.net/dwn-api-docs/android/dwn_sdk/com.darwinium.dwn_sdk/-dwn-profiling-s-d-k/index.html) #### Start profiling It usually makes sense to configure and start profiling on your activity's `onCreate()` method. For example: ``` override fun onCreate(savedInstanceState: Bundle?) { dwnProfiling.start() super.onCreate(savedInstanceState) // ...other view logic setContentView(R.layout.example_view) ``` #### Adding fields for Behavioral Biometrics Darwinium can profile behavioral biometrics for android Text Views. This is done using the `.addTextView(textViewRef, darwiniumContext)` function. For example: ``` val nameInput = this.findViewById(R.id.txtName) val passwordInput = this.findViewById(R.id.txtPassword) dwnProfiling.addTextView(nameInput, "USER_NAME") dwnProfiling.addTextView(passwordInput, "PASSWORD") ``` darwiniumContext must currently be one of hard coded values from: [Global Contexts](https://dahibthxi6hbt.cloudfront.net/dwn-api-docs/javascript/docs/global.html#Contexts) #### Collecting/sending profiling data You will want to provide the intelligence gathered by SDK profiling upon the submit action from end user (eg. press login), and API request to your backend occurs. The simplest way of achieving this is to add profile data as a header, `Dwn-Profiling`, to your existing request. Consider the following example: ``` //you can collect profiling at any time. //this is a base64 encoded string val fpData = dwnProfiling.collect() val request = Request.Builder() .url("https://path/to/your/api") .post(body) .addHeader("Dwn-Profiling", fpData) .build() ``` - An alternative collection approach exists with `collectAsync` function. That is instead invoked directly after `profiling.start` and will return the profileBlob async after collecting device attributes. The downside of that is it will not capture any profiling (eg. behaviour biometrics, remote access, phone call) if they occur after the collection. #### Permissions Darwinium's android SDK is able to use a number of extended permissions to obtain profiling data. These can be edited in `AndroidManifest.xml`: ``` ``` You can delegate the process of requesting permissions to the SDK using the combination of `dwnProfiling.requestPermissions()` and an `onRequestPermissionsResult` handler in your activity similar to the following: ``` override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) dwnProfiling.processPermissions(requestCode, grantResults) } ``` ### Setup - iOS Darwinium's iOS SDK minimum version is **iOS 12.0** and above. [Release Notes SDK](/v1/docs/release-notes-sdk#ios) shows released Darwinium SDK versions. #### Add the Darwinium SDK as a package dependency The SDK supports both Swift Package Manager (SPM) and CocoaPods. For **SPM**, add Darwinium sdk by using the following URL ``` https://packages.darwinium.com/sdk/dwn_ios_sdk.git ``` For **CocoaPods**, add the following lines in the Podfile ``` pod 'dwn_ios_sdk', :git => 'https://packages.darwinium.com/sdk/dwn_ios_sdk.git', :tag => '2.4.0' ``` Darwinium SDK depends on SwiftProtobuf which will be automatically loaded when dwn_ios_sdk loaded. #### Example: Adding using XCode Using XCode, Navigate to your project settings and select the **Package Dependencies** tab: ![Screenshot 2023-12-11 at 2.51.06 PM.png](https://cdn.document360.io/db6f7316-640d-4099-b5a1-b01b4dbd17fc/Images/Documentation/Screenshot%202023-12-11%20at%202.51.06%E2%80%AFPM.png?sv=2026-02-06&spr=https&st=2026-11-19T12%3A35%3A27Z&se=2026-11-19T13%3A35%3A27Z&sr=b&sp=r&sig=86LdRd4Elg7tAX5bRz9%2FvQ7G0URWDLVDK7ZUNDgVqN0%3D) If using SPM for example, click the "+" button. In the top right-hand side enter the following package URL: ``` https://packages.darwinium.com/sdk/dwn_ios_sdk.git ``` You will be prompted for a username and password. Enter the details collected in [Initial configuration & Repository Access](/v1/docs/mobile-sdk-deployment#initial-configuration-repository-access). This will provide a package called **dwn_ios_sdk**. Add this as a dependency, and ensure that your project is selected as a target. #### Add profiling boilerplate Identify a view that you wish to have profiled, and add the following: ``` import DwnSDK_Framework ``` #### Start Profiling In your view code, create and start your profiling. [SDK integration example](https://dahibthxi6hbt.cloudfront.net/dwn-api-docs/ios/documentation/dwnsdk_framework/dwnprofilingsdk) [Inline Frame Example](https://dahibthxi6hbt.cloudfront.net/dwn-api-docs/ios/documentation/dwnsdk_framework/dwnprofilingsdk/index.html) #### Adding Fields for Behavioral Biometrics Darwinium can profile behavioral biometrics for iOS Text Views. This is done using one of the following functions: `.addTextField(placeholder, darwiniumContext)` `.addTextField(tag, darwiniumContext)` `.addTextView(tag, darwiniumContext)` For example: ``` sdk.addTextField(placeholder: "User name", context: "user_name") sdk.addTextField(tag: 1234, context: "password") sdk.addTextView(tag: 5678, context: "email") ``` darwiniumContext must currently be one of hard coded values from: [Global Contexts](https://dahibthxi6hbt.cloudfront.net/dwn-api-docs/javascript/docs/global.html#Contexts) #### Collecting / Sending profiling data You will want to provide the intelligence gathered by SDK profiling upon the submit action from end user (eg. press login), and API request to your backend occurs. The simplest way of achieving this is to add profile data as a header, `Dwn-Profiling`, to your existing request. Consider the following example: ``` let fpData = sdk.collect() var request = URLRequest(url: URL(string: "https://path/to/your/api")!,timeoutInterval: Double.infinity) //append profiling as a header to your existing request request.addValue(fpData, forHTTPHeaderField: "Dwn-Profiling") ``` - An alternative collection approach exists with `collectAsync` function. That is instead invoked directly after `profiling.start` and will return the profileBlob async after collecting device attributes. The downside of that is it will not capture any profiling (eg. behaviour biometrics, remote access, phone call) if they occur after collection. #### Permissions Darwinium's iOS profiling is greatly enhanced by enabling [`AppTrackingTransparency`](https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/requesttrackingauthorization(completionhandler:)) and [CoreLocation](https://www.hackingwithswift.com/read/22/2/requesting-location-core-location) (GPS). We do not explicitly request these permissions ourselves, and they must be manually requested through code in your views/ changes to your `Info.plist`. ### Generate Event including the Profiling Data After collecting profiling data, the Darwinium risk engine should be invoked. That decodes the profileBlob and returns risk assessment about the user action. If using an Edge Deployment to generate events, adding the profileBlob to a header dwn-profiling on the existing request to your back end is sufficient. The Darwinium Edge worker will extract the profiling data from the request directly. If using API to generate events, the profileBlob should be sent to your backend and then included as header dwn-profiling on the API call to Darwinium. See: - [Calling the Event API](/v1/docs/journey-update-api) - [Example Event API Code](/v1/docs/example-api-code) Toubleshooting: CORS, CSP and other considerations See: [Darwinium Profiling](/v1/docs/darwinium-profiling) to ensure packet fingerprinting outbound requests are allowed and CORS will accept the dwn-profiling header Profile Blob size Size of largest profileBlobs typically 4-5kb - May need to increase permitted header length granted to the request - If a form POST, dwn-profiling can be included in request body - The more behavioural biometrics fields mapped, the larger the profileBlob size ### Tracking Journeys with the SDK + CDN You may use a session cookie to join steps as part of a journey, however more often than not mobile APIs will use a different session management method. It's common for an ephemeral authorization token (such as a JWT or a random string) to be returned to the client from a login call, which will be sent on subsequent events to prove to your backend that your app's user has already logged in. In order to join steps using SDK with such a session management method, you will need to specify a `primary_session_tie` value. This is a unique identifier that is re-used for each subsequent call which indicates to Darwinium that it is the same session. This token may be mapped from any place, including headers, URL or body. Since it is most common to use an authorization token for this purposes, session_tie attributes are considered PII, to prevent them from being sent un-hashed to Darwinium's backend, or viewed by unprivileged users. There exists additional tie attributes should there need to be hand-off, or consolidation across different session identifiers. - `primary_session_tie` - `secondary_session_tie` - `tertiary_session_tie` - `auth_token_tie`: this attribute is treated as hash only. Only truly anonymised one way hash is taken, not clear or encrypted form. This enables it to be used to map authorization tokens, where those are the defacto session identifiers. In the following example: a journey consists of two POST requests: `/login` and `/transact`. The first takes a JSON login request with a username (mapped below) and password (not mapped) and on success, returns a JSON body containing a field called `sessionId`. This `sessionId` field is then sent in the request body of subsequent events to mark this user as already having been authenticated. Request for `/login`: ``` { "username": "your name", } ``` Response for `/login`: ``` { "sessionId": "xxxxxxxxxx" } ``` Request for `/transact`: ``` { "sessionId": "xxxxxxxxxx" } ``` This journey will ensure that Darwinium treats this entire session as being part of the same journey. ``` api_version: darwinium.com/api/journey/v1 journey_name: link_device steps: - step_name: login event_type: pre_authentication proxy_event: url: /login host: domain method: POST url_match_type: Exact request: body_rule: jsonpath: - name: $.username extract_to_attribute: identity['ACCOUNT'].username.username response: body_rule: jsonpath: - name: $.sessionId extract_to_attribute: primary_session_tie - step_name: transaction proxy_event: url: /transact host: sessiontie method: POST url_match_type: Prefix request: body_rule: jsonpath: - name: $.sessionId extract_to_attribute: primary_session_tie ``` Mapping from response When you map a session_tie from the response, it will mean that the next event with this value mapped in the request will be considered to be in the same journey. However, it will not resolve to see if this value has been seen before. This is because in practice session tokens contained in the response are almost always newly issued tokens. #### Refreshing Session Tie In your app, there may be a facility to allow a new ephemeral authorization token to be re-issued during the same session. Darwinium can be made aware of this by mapping the old token into the request and the new token into the response. In this example (following the one above), there is an API to refresh the token called `/refresh-token`, which takes the existing ephemeral authorization token in the request and issues the new one in the response (i.e. follows the same format as the request for transact). The configuration to follow this session and replace the session_tie with a new one is below. ``` - step_name: transaction proxy_event: url: /refresh-token host: sessiontie method: POST url_match_type: Prefix request: body_rule: jsonpath: - name: $.sessionId extract_to_attribute: primary_session_tie response: body_rule: jsonpath: - name: $.sessionId extract_to_attribute: primary_session_tie ``` ::: ### Example Projects Barebones boilerplate projects are available for both Android and iOS using our git repo. Follow [the Initial Configuration and Repository Access](/v1/docs/mobile-sdk-deployment#initial-configuration-repository-access) guide above to obtain an api token, and checkout the projects below: #### Android ``` git clone https://packages.darwinium.com/sdk/dwn_android_sdk_sample.git ``` #### iOS ``` git clone https://packages.darwinium.com/sdk/dwn_ios_sdk_sample.git ```