Data Wallet (Aries) SDKs
The following steps outline how developers can integrate Data Wallet SDKs for Android and iOS into their existing Android or iOS applications.
Step 01: Installation
Use the following code to add depedency:
- Android
- iOS
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://repo.sovrin.org/repository/maven-public'}
maven {
name = "GitHubPackages"
url 'https://maven.pkg.github.com/L3-iGrant/ama-android-sdk'
credentials {
username = "L3-iGrant"
password = <Contact to get password>
}
}
}
dependencies {
implementation 'com.github.L3-iGrant:data_wallet:2024.6.2'
}
Additional dependencies:
dependencies {
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-dynamic-links-ktx'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'org.hyperledger:indy:1.16.0'
implementation 'net.java.dev.jna:jna:5.6.0'
implementation 'org.apache.commons:commons-lang3:3.7'
implementation 'commons-io:commons-io:2.8.0'
implementation('com.squareup.retrofit2:retrofit:2.7.1') {
exclude module: 'okhttp'
}
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.okhttp3:okhttp:4.3.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.3.1'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.airbnb.android:lottie:3.5.0'
implementation 'org.greenrobot:eventbus:3.1.1'
annotationProcessor "org.greenrobot:eventbus-annotation-processor:3.1.1"
implementation 'com.github.koushikcse:LoadingButton:1.7'
implementation 'com.github.mediapark-pk:Base58-android:0.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
implementation 'com.tbuonomo:dotsindicator:4.2'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
}
Install SDK from CocoaPods. To install, add the following line to your Podfile:
pod 'ama_ios_sdk'
Add sources to Podfile as shown:
use_modular_headers!
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/hyperledger/indy-sdk.git'
source 'https://github.com/L3-iGrant/covid19-global-sdk-iOS-specs.git'
source 'https://github.com/portto/secp256k1.swift'
Save the Podfile and run the following command in Terminal
pod install
Disable bitcode: Go to the build settings for the target. Search for "Enable Bitcode" and set it to No.
Step 02: Initialise Data Wallet
- Android
- iOS
DataWallet.initializeSdk(
this,
object : InitializeWalletCallback {
override fun progressUpdate(progress: Int) {
when (progress) {
InitializeWalletState.INITIALIZE_WALLET_STARTED -> {}
InitializeWalletState.INITIALIZE_WALLET_EXTERNAL_FILES_LOADED -> {}
InitializeWalletState.POOL_CREATED -> {}
InitializeWalletState.WALLET_OPENED -> {
DataWalletConfigurations.registerForSubscription(this)
}
}
}
},
LedgerNetworkType.getSelectedNetwork(this)
)
Import the SDK into your code using the following import statement.
import ama_ios_sdk
let delegate = // Set your delegate conforming to AriesMobileAgentDelegate
AriesMobileAgent.shared.configureWallet(delegate: delegate) { success in
if let success = success, success {
// Wallet configuration successful
} else {
// Wallet configuration failed
}
}
This function initialises and configures the Data Wallet. It takes a completion block as a parameter, which is called when the wallet configuration is completed. The success parameter indicates whether the wallet configuration was successful.
Supported Wallet Functions
Show Wallet UI
This function presents the data wallet's home view. The wallet home provides a user interface for managing wallet contents, accessing shared data, and performing wallet-related operations.
- Android
- iOS
DataWallet.showWallet(this)
AriesMobileAgent.shared.showDataWalletHomeViewController(showBackButton: true)
Show Connections UI
This function presents the connections view of the data wallet. This view displays the list of established connections, allowing users to manage their connections, view connection details, and perform connection-related actions.
- Android
- iOS
DataWallet.showConnections(this)
AriesMobileAgent.shared.showDataWalletConnectionsViewController()
Show Notifications UI
This function presents the data wallet's notifications views. This view provides a user interface for managing wallet notifications, such as receiving and viewing notifications related to data sharing or wallet updates.
- Android
- iOS
DataWallet.showNotifications(this)
AriesMobileAgent.shared.showDataWalletNotificationViewController()
Show MySharedData UI
This function presents the share data history view of the data wallet. The share data history view displays a log of all the shared data, allowing the user to view the details of each shared item and manage data-sharing permissions.
- Android
- iOS
DataWallet.showMySharedData(this)
AriesMobileAgent.shared.showDataWalletShareDataHistoryViewController()
Show DataAgreementPolicy UI
This function enables your application, integrated with the wallet, to retrieve data agreements associated with a specific organisation. By passing the required parameters such as api_key
, organization_id
, and agreement_id
, along with a context (this
), the function securely fetches the details of the specified agreement. This capability is essential for managing data consents and agreements programmatically, ensuring that your application adheres to specified data use policies and user consents.
- Android
- iOS
DataAgreementUtils.fetchDataAgreement(
"api_key",
"organization_id",
"agreement_id",
this
)
AriesMobileAgent.shared.showDataAgreementScreen(
dataAgreementID: "agreement_id",
apiKey: "api_key",
orgId: "organization_id"
)
Delete Data Wallet
- Android
- iOS
val result = DataWallet.deleteWallet()
when (result) {
is DeleteWalletResult.Success -> {
// Show success message or perform any other action
DataWallet.releaseSdk()
}
is DeleteWalletResult.Error -> {
// Show error message
}
}
AriesMobileAgent.shared.deleteWallet(completion: { success in
if success ?? false {
// Wallet deleted successfully
}
})
Query Credentials
This is used to query credentials based on the credential definition ID
and schema ID
. It will query all the credentials if we don't pass any value(s).
- Android
- iOS
DataWallet.queryCredentials(
"credential_definition_id",
"schema_id"
)
async {
if let credentials =
await AriesMobileAgent.shared.queryCredentials(
credDefId: "cred_def_id",
schemaId: "schema_id")
{
// Process the queried credentials
}
}
Process Deeplink
This function is used when scanning a QR code or generating a clickable link that opens the Data Wallet app, facilitating connections, as well as the issuance and verification of credentials. To integrate this functionality, add the specified intent filter to the activity where the SDK is initialised.
- Android
- iOS
To register your app to open didcomm:// deeplinks, add the following:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="didcomm" />
</intent-filter>
Then, add the code below to Wallet SDK and initialise the callback -> InitializeWalletState.WALLET_OPENED.
if (intent.scheme == "didcomm"){
DataWallet.processDeepLink(this, intent.data.toString())
}
Contact support@igrant.io
Change Language
This function allows you to change the language used by the SDK. Provide the language code (e.g., "en" for English) to switch the SDK's localization to the desired language.
- Android
- iOS
This is done during initialisation. Contact support@igrant.io for more info.
// Change the SDK language to English
AriesMobileAgent.shared.changeSDKLanguage(languageCode: "en")
Connect Without a UI
This function enables your application, integrated with the wallet, to programmatically connect to another wallet—be it individual or organisational—without requiring a user interface for scanning or clicking a deep link. This feature can be particularly useful for automatically linking users to predefined organisations during app onboarding.
- Android
- iOS
DataWallet.saveConnection(
Uri.parse("connection_invitation_url"),
object : ConnectionCallback {
override fun success(
connectionId: String
) {}
override fun failure(reason: String?) {}
}
)
Not Implemented
Subscribe To Notifications
This function enables your application, integrated with the wallet, to register for subscriptions using specific arguments such as api_key
and organization_id
. It sets up a listener to process incoming notifications by type, such as SHARE_REQUEST
or OFFER_REQUEST
. Upon notification receipt, it executes tailored logic and navigates to relevant screens based on the provided intent. This functionality is crucial for enabling dynamic, automatic responses to user interactions or system events.
- Android
- iOS
DataWalletConfigurations.registerForSubscription(this@MainActivity,
object : NotificationListener {
override fun receivedNotification(
notificationType: String,
intent: Intent
) {
when (notificationType) {
MessageTypes.SHARE_REQUEST -> {
// your logic
// intent will contain the screen to redirect
// startActivity(intent)
}
MessageTypes.OFFER_REQUEST -> {
// Do your logic
// intent will contain the screen to redirect
// startActivity(intent)
}
}
}
}
)
Not Implemented
Self Attested Credential
The ama-ios-sdk
provides applications with the ability to save, update, retrieve, and delete self-attested credentials securely.
Add
Allows the Applications can store self-attested credentials.
- Android
- iOS
val credentialId = SelfAttestedCredential.add(
title = "Test title",
description ="Sample description" , // optional
attributes = attributes,
// connectionName = "ConnectionName",
// location = "location",
connectionId = "<connectionId>", // if connection id is not there then need to provide connectionName and location
issuedDate = <timeStamp> //optional
)
var attritutes = [["Key": "Value"]]
try await SelfAttestedCredential.shared.add(
title: "Title",
description: "provide description", // optional
attributes: attritutes,
connectionID: "<connectionId>",
connectionName: "Connection name", // optional
connectionLocation: "Location", // optional
issuedDate: <Date> // optional
)
Update
Allows the Applications can update self-attested credentials.
- Android
- iOS
SelfAttestedCredential.update("<credentialId>","Title","description",attributes)
try await SelfAttestedCredential.shared.update(title: "Title", description: "description", attributes: var attritutes = [["Key": "Value"]], credentialId: "<credentialId>", connectionID: "<connectionId>")
Get
Allows the Applications can read the self-attested credential.
- Android
- iOS
val credential = SelfAttestedCredential.get("<credentialId>")
await SelfAttestedCredential.shared.get(id: "<credentialId>", completion: { title, desc, attributes in
print("title: \(title) \n\n description: \(desc) \n\n att: \(attributes)")
})
Delete
Allows the Applications can delete the self-attested credential.
- Android
- iOS
SelfAttestedCredential.delete("<credentialId>")
await SelfAttestedCredential.shared.delete(id: "<credentialId>", completion: { success in
print(success)
})
Backup and Restore
The ama-ios-sdk enables applications to backup and restore wallet data. Currently, backup and restore operations are supported only through Data Pods by igrant.io.
Before initiating backup or restore, users must have an account with Data Pods.
Backup
To initiate the backup
- Android
- iOS
DataWallet.initiateBackUp(context)
AriesMobileAgent.shared.initiateBackup()
Restore
To initiate the restore the backup. Before restoring make sure to delete wallet.
- Android
- iOS
DataWallet.initiateRestore(context, object : RestoreCallback {
override fun onRestoreSuccess() {
// Handle successful restore here
}
override fun onRestoreFailed(error: String) {
// Handle restore failure here
}
})
AriesMobileAgent.shared.initiateRestore() { success in
}