diff --git a/README.md b/README.md index 6e7db00..283c99a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ The MIRACL Trust Android SDK provides the following functionalities: - [Authentication](#authentication) - [Signing](#signing) - [QuickCode](#quickcode) +- [User Management](#user-management) ## System Requirements @@ -36,7 +37,7 @@ The MIRACL Trust Android SDK provides the following functionalities: Groovy: ```groovy - dependencies{ + dependencies { implementation "com.miracl:trust-sdk-android:1.9.0" } ``` @@ -373,7 +374,7 @@ options for that: ### Authentication -MIRACL Trust SDK offers two options: +MIRACL Trust Android SDK offers two options: - [Authenticate users on the mobile application](#authenticate-users-on-the-mobile-application) - [Authenticate users on another application](#authenticate-users-on-another-application) @@ -673,9 +674,140 @@ miraclTrust.generateQuickCode( ); ``` +### User Management + +The MIRACL Trust Android SDK provides several methods for managing users registered +on a device. These operations allow you to retrieve user information or delete +previously registered users. + +#### Get a registered user + +To retrieve a specific registered user by their User ID, use the +[getUser](https://miracl.github.io/trust-sdk-android/miracl-sdk/com.miracl.trust/-m-i-r-a-c-l-trust/get-user.html) +method: + +Kotlin: + +```kotlin +miraclTrust.getUser(userId = USER_ID) { result -> + when (result) { + is MIRACLSuccess -> { + val user = result.value + if (user != null) { + // User exists. + } else { + // No user registered with this User ID. + } + } + is MIRACLError -> { + val error = result.value + // Cannot retrieve the user due to an error. + } + } +} +``` + +Java: + +```java +miraclTrust.getUser(USER_ID, result -> { + if (result instanceof MIRACLSuccess) { + User user = + ((MIRACLSuccess) result).getValue(); + if (user != null) { + // User exists. + } else { + // No user registered with this User ID. + } + } else { + MIRACLError error = + (MIRACLError) result; + // Cannot retrieve the user due to an error. + } +}); +``` + +#### Get all registered users + +To obtain the list of all users registered on а device, call the +[getUsers](https://miracl.github.io/trust-sdk-android/miracl-sdk/com.miracl.trust/-m-i-r-a-c-l-trust/get-users.html) +method: + +Kotlin: + +```kotlin +miraclTrust.getUsers { result -> + when (result) { + is MIRACLSuccess -> { + val users = result.value + // Handle list of registered users. + } + is MIRACLError -> { + val error = result.value + // Cannot retrieve users due to an error. + } + } +} +``` + +Java: + +```java +miraclTrust.getUsers(result -> { + if (result instanceof MIRACLSuccess) { + List users = + ((MIRACLSuccess, UserStorageException>) result).getValue(); + // Handle list of registered users. + } else { + MIRACLError, UserStorageException> error = + (MIRACLError, UserStorageException>) result; + // Cannot retrieve users due to an error. + } +}); +``` + +#### Delete a registered user + +To delete a previously registered user from a device, call the +[delete](https://miracl.github.io/trust-sdk-android/miracl-sdk/com.miracl.trust/-m-i-r-a-c-l-trust/delete.html) +method: + +Kotlin: + +```kotlin +miraclTrust.delete( + user = user, + resultHandler = { result -> + when (result) { + is MIRACLSuccess -> { + // User deleted successfully. + } + is MIRACLError -> { + val error = result.value + // Cannot delete the user due to an error. + } + } + } +) +``` + +Java: + +```java +miraclTrust.delete(user, result -> { + if (result instanceof MIRACLSuccess) { + // User deleted successfully. + } else { + MIRACLError error = + (MIRACLError) result; + // Cannot delete the user due to an error. + } +}); +``` + ## Dependencies -MIRACL Trust SDK Android depends on: +MIRACL Trust Android SDK depends on: 1. [Kotlin Coroutines](https://github.com/Kotlin/kotlinx.coroutines/tree/master/ui/kotlinx-coroutines-android) 1. [Kotlin Serialization](https://github.com/Kotlin/kotlinx.serialization)