---
title: "Integrate the Network Security SDK"
slug: "nws-sdk-ig-integrate-the-sdk-1-4-0"
updated: 2026-08-20T09:39:40Z
published: 2026-08-20T09:39:40Z
canonical: "docs.onespan.com/nws-sdk-ig-integrate-the-sdk-1-4-0"
---
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onespan.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Integrate the Network Security SDK
## Android
For the SDK to function, you need to add the required manifest permissions and integrate the SDK.
### Manifest permissions
Add the following to the AndroidManifest.xml file:
```plaintext
```
### Integration
You can integrate the SDK either via a local Maven repository, or with an aar file.
#### Integration via local Maven repository
The SDK product package includes a local Maven repository in the maven/ folder. This resolves transitive dependencies automatically and enables inline KDoc in Android Studio.
Copy the maven/ folder from the SDK package into your app's directory (i.e. together with build.gradle), then add the following to build.gradle:
```plaintext
repositories {
maven { url uri("${rootDir}/app/maven") }
}
dependencies {
implementation 'com.onespan:sdk_network_security_android:+'
}
```
#### Integration via aar file (flat dependency)
Place the NetworkSecuritySDK.aar file from the SDK package into your app’s aars/ folder, then add the following to build.gradle:
```plaintext
repositories {
flatDir { dirs 'aars' }
}
dependencies {
implementation(name: 'NetworkSecuritySDK', ext: 'aar')
implementation 'androidx.core:core-ktx:1.15.0'
}
```
### Usage
Follow these steps:
1. Create an instance.
```plaintext
val networkSecurity = NetworkSecurity.create(applicationContext)
```
2. Retrieve the current network information (one-shot).
```plaintext
networkSecurity.getCurrentNetworkInfo { info ->
println("Type: ${info.type}")
println("Secure: ${info.isSecure}")
println("VPN: ${info.vpnConnectionStatus}")
println("Wi-Fi: ${info.wifiInfo?.ssid}")
println("Cellular: ${info.cellularInfo?.carrierName}")
}
```
3. Monitor for network changes.
```plaintext
// Start listening
networkSecurity.registerNetworkChangeListener { info ->
println("Network changed: ${info.type}")
}
// Stop listening (e.g. in onDestroy)
networkSecurity.unregisterNetworkChangeListener()
```
4. Get user-installed CA certificates.
```plaintext
try {
val certs = networkSecurity.getUserInstalledCertificates()
certs.forEach { cert ->
println("Alias: ${cert.alias}, Subject: ${cert.certificate.subjectDN}")
}
} catch (e: NetworkSecuritySDKException) {
println("Error ${e.errorCode}")
}
```
5. Get SDK version.
```plaintext
println(networkSecurity.getVersion())
// or statically:
println(NetworkSecurity.VERSION)
```
### Error handling
All SDK methods can return errors. When `NetworkSecuritySDKException` is thrown, determine the cause by checking the exception’s `errorCode` against `NetworkSecuritySDKErrorCodes`:
| Code | Message | Meaning |
| --- | --- | --- |
| -2100 | `INTERNAL_ERROR` | Unexpected internal error |
| -2101 | `CONTEXT_NULL` | Context was null |
| -2102 | `PERMISSION_DENIED` | Required permission not granted |
| -2103 | `NO_ACTIVE_DATA_NETWORK` | Device is offline |
| -2104 | `USER_CA_CERTS_UNAVAILABLE` | Could not read certificate store |
## iOS
To use the Network Security SDK in your iOS project
1. Link NetworkSecuritySDK.xcframework from the OneSpan Mobile Security Suite package to your Xcode project (linked framework and libraries).
2. Add the location permission for the key: Privacy - Location When In Use Usage Description
3. Add the Access Wi-Fi Information capability.
You are now ready to use the Network Security SDK.
## API reference documentation and sample applications
To learn more about the public APIs and their functions, exceptions, and error codes, refer to the technical documentation that is included in the product package for each SDK and each platform. In the product package, you can also find the sample applications provided for each platform to see examples of how the SDKs can be used.
> These sample apps are intended only to demonstrate basic scenarios and SDK usage. They are not designed to be copied directly into production projects!