Skip to main content

Consent Management SDKs

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:

For Gradle:

settings.gradle
dependencies {
implementation 'com.github.L3-iGrant:privacy-dashboard-android:<latest release>'
}

For Maven:

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

Step 02: Initialise Privacy Dashboard

For Gradle:

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

MyActivity.kt
PrivacyDashboard.showPrivacyDashboard()
.withApiKey("API_key")
.withUserId("User_ID")
.withBaseUrl("Base_URL")
.withOrganisationId("Org ID")
.start(this)

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

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)

MyActivity.kt
.withLocale("language_code")

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

MyActivity.kt
.enableUserRequest()

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

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.

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.

MyActivity.kt
.withDataAgreementIDs(arrayListOf("<Data Agreement ID 1>", "<Data Agreement ID 2>", "<Data Agreement ID 3>"))

Supported Privacy Dashboard Functions

Data Sharing UI

To initiate the Data sharing UI.

Register activity for result to get the response back from the Data sharing UI.

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

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).

MyActivity.kt
.secondaryButtonText(<Button text>)

Opt-in to Data Agreement

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

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

Read Data Agreement

This function is used to fetch the data agreement using dataAgreementId

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

Show Data Agreement Policy

This function is used to show the data agreement policy.

MyActivity.kt
PrivacyDashboard.showDataAgreementPolicy()
.withDataAgreement("data_agreement_response")
.withLocale("en")
.start(this)

Create an Individual

This function is used to create an individual.

MyActivity.kt
PrivacyDashboard.createAnIndividual(
baseUrl = "base_url",
apiKey = "api_key",
name = "optional",
email = "optional",
phone = "optional"
)

Read an Individual

This function is used to fetch an individual.

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

Update an Individual

This function is used to update an individual.

MyActivity.kt
PrivacyDashboard.updateTheIndividual(
baseUrl = "base_url",
apiKey = "api_key",
name = "name",
email = "email",
phone = "phone",
individualId = "individual_id"
)

List Individuals

This function is used to list all individuals.

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