Skip to content
Open
Show file tree
Hide file tree
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
61 changes: 39 additions & 22 deletions content/docs/android-kotlin/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,74 @@ import { BadgeGroup } from '@/app/components/badge';

## Prerequisites

- An Android application source code (Support for Android 5.0 or later).
- An Android device or emulator running Android 5.0 or later.
- A Reclaim account where you've created an app and have the app id, app secret.
- A provider id that you've added to your app in Reclaim Devtools.
- Android 5.0+ (API level 21)
- [Reclaim account](https://dev.reclaimprotocol.org/explore) with app ID, app secret, and provider ID ([Get API Key guide](/api-key))

## Example

[Complete Android example](https://github.com/reclaimprotocol/reclaim-inapp-android-sdk/tree/main/example) with Jetpack Compose

## Installation

Add the following repositories to your `settings.gradle` file's repositories block or at the end of settings.gradle:
### Add Repositories

Add to `settings.gradle`:

```groovy
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
String flutterStorageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"
String reclaimStorageUrl = System.env.RECLAIM_STORAGE_BASE_URL ?: "https://reclaim-inapp-sdk.s3.ap-south-1.amazonaws.com/android/0.3.0/repo"
String reclaimStorageUrl = System.env.RECLAIM_STORAGE_BASE_URL ?: "https://reclaim-inapp-sdk.s3.ap-south-1.amazonaws.com/android/repo"
repositories {
google()
mavenCentral()
maven {
url "$reclaimStorageUrl"
}
maven {
url "$flutterStorageUrl/download.flutter.io"
}
maven { url "$reclaimStorageUrl" }
maven { url "$flutterStorageUrl/download.flutter.io" }
}
}
```

You can replace the version mentioned in the url of `reclaimStorageUrl` with the version of SDK you're using. Latest is `0.3.0`.
### Add Dependency

Some projects may require you to add the repositories to the root `build.gradle` file or your app-level `build.gradle` file's allprojects section.

Next, add the following to your app level `build.gradle` file:
Add to app-level `build.gradle`:

```groovy
implementation "org.reclaimprotocol:inapp_sdk:0.3.0"
implementation "org.reclaimprotocol:inapp_sdk:0.21.0"
```

Add the following to your app level `AndroidManifest.xml` file under the `<application>` tag:
### Configure AndroidManifest.xml

Add inside `<application>` tag:

```xml
<activity
android:name="org.reclaimprotocol.inapp_sdk.ReclaimActivity"
android:theme="@style/Theme.ReclaimInAppSdk.LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
/>
android:windowSoftInputMode="adjustResize" />

<meta-data android:name="org.reclaimprotocol.inapp_sdk.APP_ID"
android:value="<YOUR_RECLAIM_APP_ID>" />
android:value="YOUR_RECLAIM_APP_ID" />
<meta-data android:name="org.reclaimprotocol.inapp_sdk.APP_SECRET"
android:value="<YOUR_RECLAIM_APP_SECRET>" />
android:value="YOUR_RECLAIM_APP_SECRET" />
```

### Add Permissions

Required permission in `AndroidManifest.xml`:

```xml
<uses-permission android:name="android.permission.INTERNET" />
```

Optional permissions (requested by specific providers at runtime):

```xml
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
```
98 changes: 65 additions & 33 deletions content/docs/android-kotlin/usage.mdx
Original file line number Diff line number Diff line change
@@ -1,68 +1,100 @@
---
title: Usage
description: Reclaim Protocol's InApp Android SDK for ZK proof generations for requests with an in-app experience of web verification
description: Reclaim Protocol's InApp Android SDK for ZK proof generation with in-app web verification
---

## Usage
## Basic Usage

To use ReclaimInAppSdk in your project, follow these steps:

1. Import the ReclaimInAppSdk module into your Kotlin/Java file.
### 1. Import the SDK

```kotlin
import org.reclaimprotocol.inapp_sdk.ReclaimVerification
```

2. Create a request object.
### 2. Create Request

Using credentials from AndroidManifest.xml:

```kotlin
val request = ReclaimVerification.Request(
appId = "YOUR_APP_ID",
secret = "YOUR_APP_SECRET",
providerId = "YOUR_PROVIDER_ID"
)
val request = ReclaimVerification.Request.fromManifestMetaData(
context = context,
providerId = "YOUR_PROVIDER_ID"
)
```

Or if you have added the APP_ID and APP_SECRET metadata to your AndroidManifest.xml file, you can create the request object using the `ReclaimVerification.Request.fromManifestMetaData` method.
Or pass credentials directly:

```kotlin
val request = ReclaimVerification.Request.fromManifestMetaData(
context = context,
providerId = "YOUR_PROVIDER_ID"
)
val request = ReclaimVerification.Request(
appId = "YOUR_APP_ID",
secret = "YOUR_APP_SECRET",
providerId = "YOUR_PROVIDER_ID"
)
```

3. Start the verification flow.

### 3. Start Verification

```kotlin
ReclaimVerification.startVerification(
context = context,
request = request,
handler = object : ReclaimVerification.ResultHandler {
override fun onException(exception: ReclaimVerification.ReclaimVerificationException) {
Log.e("MainActivity", "Something went wrong", exception)
val reason = when (exception) {
is ReclaimVerification.ReclaimVerificationException.Failed -> "Failed because: ${exception.reason}"
is ReclaimVerification.ReclaimVerificationException.Cancelled -> "Verification cancelled"
is ReclaimVerification.ReclaimVerificationException.Dismissed -> "Dismissed by user"
is ReclaimVerification.ReclaimVerificationException.SessionExpired -> "Session expired"
}
Log.d("MainActivity", "reason: $reason")
override fun onResponse(response: ReclaimVerification.Response) {
// Verification successful
Log.d("Reclaim", "Proofs: ${response.proofs}")
}

override fun onResponse(response: ReclaimVerification.Response) {
Log.d("MainActivity", response.toString())
override fun onException(exception: ReclaimVerification.ReclaimVerificationException) {
when (exception) {
is ReclaimVerification.ReclaimVerificationException.Failed ->
Log.e("Reclaim", "Failed: ${exception.reason}")
is ReclaimVerification.ReclaimVerificationException.Cancelled ->
Log.d("Reclaim", "User cancelled")
is ReclaimVerification.ReclaimVerificationException.Dismissed ->
Log.d("Reclaim", "User dismissed")
is ReclaimVerification.ReclaimVerificationException.SessionExpired ->
Log.d("Reclaim", "Session expired")
}
}
}
)
```

The returned result `ReclaimVerification.ResultHandler.onResponse` in is a `ReclaimVerification.Response` object. This object contains a response that has proofs, exception, and the sessionId if the verification is successful.
## Complete Request Parameters

```kotlin
val request = ReclaimVerification.Request(
// Required
appId = "YOUR_APP_ID",
secret = "YOUR_APP_SECRET",
providerId = "YOUR_PROVIDER_ID",

// Optional
session = ReclaimVerification.ReclaimSessionInformation(
sessionId = "session-id",
timestamp = "1234567890",
signature = "signature"
),

contextString = "additional-context", // Additional context data

parameters = mapOf( // Custom provider parameters
"customParam" to "value"
),

providerVersion = ReclaimVerification.Request // Specify provider version
.ProviderVersion.resolved("1.0.0")
)
```

If the verification is cancelled or failed, the handler's `ReclaimVerification.ResultHandler.onException` method is called with a `ReclaimVerification.ReclaimVerificationException` object.
## Troubleshooting

## Example
### Cronet Errors (Devices without Google Play Services)

- See the [Reclaim Compose Example - Android](https://github.com/reclaimprotocol/reclaim-inapp-android-sdk/tree/main/example/README.md) for a complete example of how to use the SDK in an Android application.
If you see Cronet-related errors on devices without Play Services, add embedded Cronet:

```gradle
dependencies {
implementation("org.chromium.net:cronet-embedded:141.7340.3")
}
```