---
id: consent-management-sdks
title: Consent Management SDKs
description: Integrate the iGrant.io consent management Privacy Dashboard SDKs for Android, iOS, and cloud into your application.
keywords: [consent management, SDK, Android SDK, iOS SDK, Privacy Dashboard, GDPR, data agreement, consent record]
hide_title: false
sidebar_label: Quick Start with SDKs
slug: /consent-management-sdks/
---

> **Build this with an AI coding agent.** Install the iGrant.io Agent Skills, then ask your agent to build the integration:
>
> ```bash
> npx skills add L3-iGrant/skills
> ```


import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

The following steps outline how developers can integrate iGrant.io consent management (Privacy Dashboard) Android/iOS/Cloud SDKs into your application.

## Step 01: Installation

Use the following code to add depedency:

```mdx-code-block
<Tabs>
<TabItem value="gradle" label="Android">
```

**For Gradle:**

```groovy showLineNumbers title="settings.gradle"
dependencies {
  implementation 'com.github.L3-iGrant:privacy-dashboard-android:<latest release>'
}
```

**For Maven:**

```xml showLineNumbers title="pom.xml"
<dependency>
    <groupId>com.github.L3-iGrant</groupId>
    <artifactId>privacy-dashboard-android</artifactId>
    <version><latest release></version>
</dependency>
```

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="iOS" label="iOS">
```

Install SDK using SPM. To install, do the following:
- In Xcode, select **File → Add Packages...**
- Enter the URL: `https://github.com/L3-iGrant/privacy-dashboard-ios`

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="Cloud" label="Cloud">
```

Use the following command to pull the docker image to the local repository. You may skip this and run it directly from the docker hub (as in Step 02).

```bash
docker pull igrantio/bb-consent-privacy-dashboard:<tag>
```

Example: To pull version 2023.11.4 execute the following command in the terminal:

```bash
docker pull igrantio/bb-consent-privacy-dashboard:2023.11.4
```

```mdx-code-block
</TabItem>
</Tabs>
```

## Step 02: Initialise Privacy Dashboard

```mdx-code-block
<Tabs>
<TabItem value="gradle" label="Android">
```

**For Gradle:**

We can initiate the privacy dashboard using the below code block:

```kotlin showLineNumbers title="MyActivity.kt"
PrivacyDashboard.showPrivacyDashboard()
    .withApiKey("API_key")
    .withUserId("User_ID")
    .withBaseUrl("Base_URL")
    .withOrganisationId("Org ID")
    .withViewMode(ViewMode.BottomSheet)
    .start(this)
```

We can also show the privacy dashboard with `accessToken`. For that use the below

```kotlin showLineNumbers title="MyActivity.kt"
.withAccessToken("accessToken")
```
> **_Note:_** If we have `accessToken` then no need to pass `API key` and `User ID`

To set the language we just need to add the following before the `start(this)`

```kotlin showLineNumbers title="MyActivity.kt"
.withLocale("language_code")
```

To enable user requests we just need to add the following before the `start(this)`

```kotlin showLineNumbers title="MyActivity.kt"
.enableUserRequest()
```

To enable Ask me we just need to add the following before the `start(this)`

```kotlin showLineNumbers title="MyActivity.kt"
.enableAskMe()
```

To listen for consent changes, add the following code before calling `start(this)`. This will notify you whenever a consent status update occurs.

```kotlin showLineNumbers title="MyActivity.kt"
.withConsentChangeListener(object : ConsentChangeListener {  
	override fun onConsentChange(status: Boolean, dataAgreementId: String,consentRecordId: String) {  
		Log.d(TAG, "onConsentChange: $status, $dataAgreementId, $consentRecordId")  
	}  
})
```

To display only specific data agreements in the privacy dashboard, use the following code before `start(this)`.  
If you want to show all available data agreements, simply omit this step.

```kotlin showLineNumbers title="MyActivity.kt"
.withDataAgreementIDs(arrayListOf("<Data Agreement ID 1>", "<Data Agreement ID 2>", "<Data Agreement ID 3>"))
``````

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="iOS" label="iOS">
```

```swift showLineNumbers title="MyViewController.swift"
import PrivacyDashboardiOS

PrivacyDashboard.showPrivacyDashboard(
  withApiKey: "apiKey",
  withUserId: "userID",
  withOrgId: "orgID",
  withBaseUrl: "baseURL",
  turnOnAskme: "bool",
  turnOnUserRequest: "bool",
  turnOnAttributeDetail: "bool",
  viewMode: .bottomSheet)
```

We can show the privacy dashboard with `accessToken` (optional parameter).

> **_Note:_** If we have `accessToken` then no need to pass `API key` and `User ID`

To set app language, pass language code to `withLocale`. 
Now supporting three languages ie: English, Swedish and Finnish (By default it'll be English) 

```swift showLineNumbers title="MyViewController.swift"
withLocale: "en",
```

To enable user requests, set the `turnOnUserRequest` to `true`

```swift showLineNumbers title="MyViewController.swift"
turnOnUserRequest : true
```

To enable Ask me, set the `turnOnAskme` to `true`

```swift showLineNumbers title="MyViewController.swift"
 turnOnAskme : true
```

To enable Attribute detail screen, set the `turnOnAttributeDetail` to `true`

```swift showLineNumbers title="MyViewController.swift"
 turnOnAttributeDetail : true
```

To listen for consent changes, pass `onConsentChange` as below

```swift showLineNumbers title="MyViewController.swift"
 onConsentChange: { success, dataAgreementID, consentRecordID in 
			debugPrint("Consent change here:\(success) - \(resultVal) \(consentRecordID)")  
		}
```

To display only specific data agreements in the privacy dashboard, pass `dataAgreementIDs` as below.
If you want to show all available data agreements, simply omit this parameter.

```swift showLineNumbers title="MyViewController.swift"
dataAgreementIDs: ["<Data Agreement ID 1>", "<Data Agreement ID 2>", "<Data Agreement ID 3>"]
```

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="Cloud" label="Cloud">
```

You can run the docker image either locally or directly executing the command below. In case you wish to override the base URL 
for consent-bb API server to connect to the privacy dashboard, use the following command:

```bash
docker run -v ./config.json:/usr/share/nginx/html/config/config.json -p 3030:80 igrantio/bb-consent-privacy-dashboard:2023.11.4
```

A sample configuration file is as given:

```bash
{
  "baseUrl": "https://api.igrant.dev/v2",
  "redirectUrl": "https://staging-consent-bb-privacy-dashboard.igrant.io/login",
  "clientId": "igrant-ios-app"
}
```

The privacy dashboard is accessible at [http://localhost:3030/#/login](http://localhost:3030/#/login).

```mdx-code-block
</TabItem>
</Tabs>
```

## Supported Privacy Dashboard Functions

### Data Sharing UI

To initiate the Data sharing UI.

```mdx-code-block
<Tabs>
<TabItem value="gradle" label="Android">
```
Register activity for result to get the response back from the Data sharing UI.


```kotlin showLineNumbers title="MyActivity.kt"
var resultLauncher =
    registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
        if (result.resultCode == Activity.RESULT_OK) {
            val data: Intent? = result.data
            if (data != null) {
                Log.d("Data Agreement Record", data.getStringExtra("data_agreement_record") ?: "")
            }
        }
    }
```

To initiate the Data sharing UI


```kotlin showLineNumbers title="MyActivity.kt"
val intent =
    DataSharingUI.showDataSharingUI()
        .withApiKey("API_key")
        .withUserId("user_id")
        .withDataAgreementId("data_agreement_id")
        .withThirdPartyApplication("third_party_application_name", "third_party_application_logo")
        .withBaseUrl("base_url")
        .withOrganizationId("Org ID")
        .get(this)

resultLauncher.launch(intent)
```

To set the secondary button's text. Use the following before the `start(this)`.

```kotlin showLineNumbers title="MyActivity.kt"
.secondaryButtonText(<Button text>)
```

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="iOS" label="iOS">
```

```swift showLineNumbers title="MyViewController.swift"
PrivacyDashboard.showDataSharingUI(
  apiKey: "api_key",
  userId: "user_id",
  baseUrlString: "base_url",
  dataAgreementId: "data_agreement_id",
  organisationName: "organisation_name",
  organisationLogoImageUrl: "organisation_logo",
  termsOfServiceText: "terms_of_service_text",
  termsOfServiceUrl: "terms_of_service_url",
  cancelButtonText: "cancel_button_text")
```


```mdx-code-block
</TabItem>
</Tabs>
```

### Opt-in to Data Agreement

This function is used to provide the 3PP developer to opt-in to a data agreement.

```mdx-code-block
<Tabs>
<TabItem value="gradle" label="Android">
```

```kotlin showLineNumbers title="MyActivity.kt"
PrivacyDashboard.updateDataAgreementStatus(
    dataAgreementId = "data_agreement_id",
    baseUrl = "base_url",
    apiKey = "api_key",
    userId = "user_id",
    status = true
)
```

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="iOS" label="iOS">
```

```swift showLineNumbers title="MyViewController.swift"
PrivacyDashboard.updateDataAgreementStatus(
  dataAgreementId: "data_agreement_id",
  status: "true")
```


```mdx-code-block
</TabItem>
</Tabs>
```

### Read Data Agreement

This function is used to fetch the data agreement using `dataAgreementId`

```mdx-code-block
<Tabs>
<TabItem value="gradle" label="Android">
```

```kotlin showLineNumbers title="MyActivity.kt"
PrivacyDashboard.getDataAgreement(
    dataAgreementId = "data_agreement_id",
    baseUrl = "base_url",
    apiKey = "api_key",
    userId = "user_id"
)
```

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="iOS" label="iOS">
```

```swift showLineNumbers title="MyViewController.swift"
PrivacyDashboard.readDataAgreementApi(dataAgreementId: <>) {
  success, resultVal in
  // Result val will be a callback
  // response in dictionary format
}
```

```mdx-code-block
</TabItem>
</Tabs>
```

### Show Data Agreement Policy

This function is used to show the data agreement policy.

```mdx-code-block
<Tabs>
<TabItem value="gradle" label="Android">
```

```kotlin showLineNumbers title="MyActivity.kt"
PrivacyDashboard.showDataAgreementPolicy()
    .withDataAgreement("data_agreement_response")
    .withViewMode(ViewMode.BottomSheet)
    .withLocale("en")
    .start(this)
```

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="iOS" label="iOS">
```

```swift showLineNumbers title="MyViewController.swift"
PrivacyDashboard.showDataAgreementPolicy(dataAgreementRecord: "data_agreement_response",
                                         viewMode: .bottomSheet)
```

```mdx-code-block
</TabItem>
</Tabs>
```

### Create an Individual

This function is used to create an individual.

```mdx-code-block
<Tabs>
<TabItem value="gradle" label="Android">
```

```kotlin showLineNumbers title="MyActivity.kt"
PrivacyDashboard.createAnIndividual(
    baseUrl = "base_url",
    apiKey = "api_key",
    name = "optional",
    email = "optional",
    phone = "optional",
    pushNotificationToken = "FCM_token",
    deviceType = "android"
)
```

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="iOS" label="iOS">
```

```swift showLineNumbers title="MyViewController.swift"
PrivacyDashboard.createAnIndividual(
  name: "optional",
  email: "optional",
  phone: "optional",
  pushNotificationToken: "FCM_token",
  deviceType: "ios"
) { success, resultVal in
  // Result val will be a callback
  // response in dictionary format
}

```

```mdx-code-block
</TabItem>
</Tabs>
```

### Read an Individual

This function is used to fetch an individual.

```mdx-code-block
<Tabs>
<TabItem value="gradle" label="Android">
```

```kotlin showLineNumbers title="MyActivity.kt"
PrivacyDashboard.fetchTheIndividual(
    baseUrl = "base_url",
    apiKey = "api_key",
    individualId = "individual_id"
)
```

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="iOS" label="iOS">
```

```swift showLineNumbers title="MyViewController.swift"
PrivacyDashboard.readAnIndividual(
  individualId = "individual_id"
) { success, resultVal in
  // Result val will be a callback
  // response in dictionary format
}
```

```mdx-code-block
</TabItem>
</Tabs>
```

### Update an Individual

This function is used to update an individual.

```mdx-code-block
<Tabs>
<TabItem value="gradle" label="Android">
```

```kotlin showLineNumbers title="MyActivity.kt"
PrivacyDashboard.updateTheIndividual(
    baseUrl = "base_url",
    apiKey = "api_key",
    name = "name",
    email = "email",
    phone = "phone",
    individualId = "individual_id",
    pushNotificationToken = "FCM_token",
    deviceType = "android"
)
```

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="iOS" label="iOS">
```

```swift showLineNumbers title="MyViewController.swift"
PrivacyDashboard.updateAnIndividual(
  individualId = "individual_id",
  name: "optional",
  email: "optional",
  phone: "optional",
  pushNotificationToken: "FCM_token",
  deviceType: "ios"
) { success, resultVal in
  // Result val will be a callback
  // response in dictionary format
}
```

```mdx-code-block
</TabItem>
</Tabs>
```

### List Individuals

This function is used to list all individuals.

```mdx-code-block
<Tabs>
<TabItem value="gradle" label="Android">
```

```kotlin showLineNumbers title="MyActivity.kt"
PrivacyDashboard.getAllIndividuals(
    baseUrl = "base_url",
    apiKey = "api_key",
    offset = "offset(int)",
    limit = "limit(int)"
)
```

```mdx-code-block
</TabItem>
```

```mdx-code-block
<TabItem value="iOS" label="iOS">
```

```swift showLineNumbers title="MyViewController.swift"
PrivacyDashboard.fetchAllIndividuals(
  individualId = "individual_id"
) { success, resultVal in
  // Result val will be a callback
  // response in dictionary format
}
```

```mdx-code-block
</TabItem>
</Tabs>
```
