Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 135 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
}
```
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<User, UserStorageException>) result).getValue();
if (user != null) {
// User exists.
} else {
// No user registered with this User ID.
}
} else {
MIRACLError<User, UserStorageException> error =
(MIRACLError<User, UserStorageException>) 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<User> users =
((MIRACLSuccess<List<User>, UserStorageException>) result).getValue();
// Handle list of registered users.
} else {
MIRACLError<List<User>, UserStorageException> error =
(MIRACLError<List<User>, 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<Unit, UserStorageException> error =
(MIRACLError<Unit, UserStorageException>) 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)
Expand Down