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:
- Android
- iOS
- Cloud
For Gradle:
dependencies {
implementation 'com.github.L3-iGrant:privacy-dashboard-android:<latest release>'
}
For Maven:
<dependency>
<groupId>com.github.L3-iGrant</groupId>
<artifactId>privacy-dashboard-android</artifactId>
<version><latest release></version>
</dependency>
PrivacyDashboardiOS is available through CocoaPods. To install it, simply add the following line to your Podfile after all pod set up done:
pod 'PrivacyDashboardiOS','<latest version>'
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).
docker pull igrantio/bb-consent-privacy-dashboard:<tag>
Example: To pull version 2023.11.4 execute the following command in the terminal:
docker pull igrantio/bb-consent-privacy-dashboard:2023.11.4
Step 02: Initialise Privacy Dashboard
- Android
- iOS
- Cloud
For Gradle:
We can initiate the privacy dashboard using the below code block:
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
.withAccessToken("accessToken")
Note: If we have
accessToken
then no need to passAPI key
andUser ID
To set the language we just need to add the following before the start(this)
.withLocale("language_code")
To enable user requests we just need to add the following before the start(this)
.enableUserRequest()
To enable Ask me we just need to add the following before the start(this)
.enableAskMe()
To listen for consent changes, add the following code before calling start(this)
. This will notify you whenever a consent status update occurs.
.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.
.withDataAgreementIDs(arrayListOf("<Data Agreement ID 1>", "<Data Agreement ID 2>", "<Data Agreement ID 3>"))
import PrivacyDashboardiOS
PrivacyDashboard.showPrivacyDashboard(
withApiKey: "apiKey",
withUserId: "userID",
withOrgId: "orgID",
withBaseUrl: "baseURL",
turnOnAskme: "bool",
turnOnUserRequest: "bool",
turnOnAttributeDetail: "bool")
We can show the privacy dashboard with accessToken
(optional parameter).
Note: If we have
accessToken
then no need to passAPI key
andUser 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)
withLocale: "en",
To enable user requests, set the turnOnUserRequest
to true
turnOnUserRequest : true
To enable Ask me, set the turnOnAskme
to true
turnOnAskme : true
To enable Attribute detail screen, set the turnOnAttributeDetail
to true
turnOnAttributeDetail : true
To listen for consent changes, pass onConsentChange
as below
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.
dataAgreementIDs: ["<Data Agreement ID 1>", "<Data Agreement ID 2>", "<Data Agreement ID 3>"]
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:
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:
{
"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.
Supported Privacy Dashboard Functions
Data Sharing UI
To initiate the Data sharing UI.
- Android
- iOS
Register activity for result to get the response back from the Data sharing UI.
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
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)
.
.secondaryButtonText(<Button text>)
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")
Opt-in to Data Agreement
This function is used to provide the 3PP developer to opt-in to a data agreement.
- Android
- iOS
PrivacyDashboard.updateDataAgreementStatus(
dataAgreementId = "data_agreement_id",
baseUrl = "base_url",
apiKey = "api_key",
userId = "user_id",
status = true
)
PrivacyDashboard.updateDataAgreementStatus(
dataAgreementId: "data_agreement_id",
status: "true")
Read Data Agreement
This function is used to fetch the data agreement using dataAgreementId
- Android
- iOS
PrivacyDashboard.getDataAgreement(
dataAgreementId = "data_agreement_id",
baseUrl = "base_url",
apiKey = "api_key",
userId = "user_id"
)
PrivacyDashboard.readDataAgreementApi(dataAgreementId: <>) {
success, resultVal in
// Result val will be a callback
// response in dictionary format
}
Show Data Agreement Policy
This function is used to show the data agreement policy.
- Android
- iOS
PrivacyDashboard.showDataAgreementPolicy()
.withDataAgreement("data_agreement_response")
.withLocale("en")
.start(this)
PrivacyDashboard.showDataAgreementPolicy(dataAgreementRecord: "data_agreement_response")
Create an Individual
This function is used to create an individual.
- Android
- iOS
PrivacyDashboard.createAnIndividual(
baseUrl = "base_url",
apiKey = "api_key",
name = "optional",
email = "optional",
phone = "optional"
)
PrivacyDashboard.createAnIndividual(
name: "optional",
email: "optional",
phone: "optional"
) { success, resultVal in
// Result val will be a callback
// response in dictionary format
}
Read an Individual
This function is used to fetch an individual.
- Android
- iOS
PrivacyDashboard.fetchTheIndividual(
baseUrl = "base_url",
apiKey = "api_key",
individualId = "individual_id"
)
PrivacyDashboard.readAnIndividual(
individualId = "individual_id"
) { success, resultVal in
// Result val will be a callback
// response in dictionary format
}
Update an Individual
This function is used to update an individual.
- Android
- iOS
PrivacyDashboard.updateTheIndividual(
baseUrl = "base_url",
apiKey = "api_key",
name = "name",
email = "email",
phone = "phone",
individualId = "individual_id"
)
PrivacyDashboard.updateAnIndividual(
individualId = "individual_id"
) { success, resultVal in
// Result val will be a callback
// response in dictionary format
}
List Individuals
This function is used to list all individuals.
- Android
- iOS
PrivacyDashboard.getAllIndividuals(
baseUrl = "base_url",
apiKey = "api_key",
offset = "offset(int)",
limit = "limit(int)"
)
PrivacyDashboard.fetchAllIndividuals(
individualId = "individual_id"
) { success, resultVal in
// Result val will be a callback
// response in dictionary format
}