mobile-sdk-wrapper-nativescript-okhttp is a wrapper around the Android DataDome SDK for NativeScript projects.
The project is organized as follows:
.
├── ns-datadome-android/ # Android module - Kotlin wrapper for the Android DataDome SDK
├── sample-app/ # Example NativeScript app demonstrating how to integrate the module
├── README.md # Project documentationNote: This wrapper is written in Kotlin, so Kotlin support must be enabled in your NativeScript project. Please follow the steps below to enable it. You can also refer to the official NativeScript documentation for more details.
- Set useKotlin=true in
App_Resources/Android/gradle.properties(create the file if it doesn't exist).
useKotlin=true- Configure the version of Kotlin to use in the application in App_Resources/Android/before-plugins.gradle (create the file if it doesn't exist).
project.ext {
kotlinVersion = "1.9.10"
}You have two options to integrate the wrapper into your NativeScript project, depending on your project organization and preference:
- Clone or download the
ns-datadome-androidmodule, then place in inside your NativeScript project's root folder.
your-nativescript-app/
├── app/
├── ns-datadome-android/ ← Place the module here
├── ...- Add the module as a dependency to your app.
- In your
App_Resources/Android/settings.gradle(create the file if doesn't exist):
// Adjust the path below according to your project structure.
// The path '../../../ns-datadome-android/wrapper' assumes that the module is located in the root folder of the NativeScript project.
include ':wrapper'
project(':wrapper').projectDir = new File('../../../ns-datadome-android/wrapper')- In your
App_Resources/Android/app.gradle, add the following dependencies:
implementation project(":wrapper")
implementation 'co.datadome.sdk:sdk:1.15.3'Make sure to replace 1.15.3 with the latest version of the DataDome SDK if necessary.
If you prefer not to include the entire module, you can copy the Kotlin wrapper file manually into your project.
-
Download the Kotlin wrapper file from the following path in this repository: DatadomeWrapper.kt
-
Paste it into your NativeScript app's App_Resources/Android source folder:
your-nativescript-app/
└── App_Resources/
└── Android/
└── src/
└── main/
└── java/
└── co/
└── datadome/
└── ns/
└── wrapper/
└── DatadomeWrapper.ktIn your TypeScript file, follow these steps to initialize and use the SDK:
- Declare the Kotlin namespace:
declare const co: any;- Initialize the SDK:
this.dataDomeSDKWrapper = new co.datadome.ns.wrapper.DataDomeSDKWrapper(
androidApplication,
'YOUR_API_KEY',
'YOU_APP_VERSION',
true // if you want to enable logs
);- Define the completion handler:
const completionHandler = new co.datadome.ns.wrapper.DataDomeSDKWrapper.CompletionHandler({
onSuccess(response: string) {
console.log('✅ Request succeeded:', response);
this.message = response;
},
onError(error: string) {
console.error('❌ Request failed:', error);
}
});- Make a request:
const headers = new java.util.HashMap();
headers.put('User-Agent', 'BLOCKUA');
headers.put('Accept', 'application/json');
const body = JSON.stringify({
techno: 'Nativescript',
role: 'wrapper'
});
this.dataDomeSDKWrapper.makeRequest(
'post',
'YOUR_ENDPOINT',
headers,
body,
completionHandler
);