A Flutter SDK for integrating Reclaim's verification system directly into your Flutter applications. This SDK allows you to verify user credentials and generate proofs in-app.
- In-app verification flow
- Customizable verification options
- ZK Proof generation
Add the following to your pubspec.yaml
:
dependencies:
reclaim_inapp_flutter_sdk: ^latest_version
Or, when installing from git source, add the following to your pubspec.yaml
:
dependencies:
reclaim_inapp_flutter_sdk:
git:
url: https://github.com/reclaimprotocol/reclaim-inapp-flutter-sdk.git
ref: 0.10.13
Your app performance will be severely impacted when you run debug executable on a physical device. Fixing this requires a simple change in your Xcode project xcscheme.
- Open your iOS project (*.xcworkspace) in Xcode.
- Click on the project target.
- Click on the Scheme dropdown.
- Click on the Edit Scheme button.
- Click on the Run tab.
- Click on the Arguments tab and check the Environment Variables section.
- Add the following environment variable:
- Key:
GODEBUG
- Value:
asyncpreemptoff=1
- Key:
- Click on the Close button in the dialog and build the project.
- Run the app on a physical device.
- Import the SDK in your Dart file:
import 'package:reclaim_inapp_flutter_sdk/reclaim_inapp_flutter_sdk.dart';
- Initialize the SDK with your app credentials:
Following is an exmaple.
const String appId = String.fromEnvironment('APP_ID');
const String appSecret = String.fromEnvironment('APP_SECRET');
const String providerId = String.fromEnvironment('PROVIDER_ID');
final sdk = ReclaimInAppSdk.of(context);
final proofs = await sdk.startVerification(
ReclaimVerificationRequest(
appId: appId,
providerId: providerId,
secret: appSecret,
sessionInformation: ReclaimSessionInformation.empty(),
contextString: '',
parameters: {},
claimCreationType: ClaimCreationType.standalone,
),
);
sdk.startVerificationFromUrl
: You can also start a verification with a verification url generated with any reclaim backend sdk like Reclaim Protocol: JS SDK.sdk.startVerificationFromJson
: Similar to starting verification with url, you can also start verification with the json config exported from the requested that's created with any backend SDK like Reclaim Protocol: JS SDK'sreclaimProofRequest.toJsonString()
.
The ReclaimVerificationRequest
supports the following options:
appId
: Your Reclaim application IDproviderId
: The ID of the provider you want to verify againstsecret
: Your application secret (optional if using session information)sessionInformation
: Session information for authenticationcontextString
: Additional context for the verificationparameters
: Custom parameters for the verificationclaimCreationType
: Type of claim creation (standalone or meChain)autoSubmit
: Whether to auto-submit the verificationhideCloseButton
: Whether to hide the close buttonwebhookUrl
: URL for webhook notificationsverificationOptions
: Additional verification options
The SDK throws specific exceptions that you can handle:
try {
final proofs = await sdk.startVerification(request);
} on ReclaimExpiredSessionException {
// Handle expired session
} on ReclaimVerificationManualReviewException {
// Handle manual review case
} catch (error) {
// Handle other errors if required
}
For better performance, you can pre-warm the SDK:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
ReclaimInAppSdk.preWarm();
runApp(MyApp());
}
Check out the example for a complete implementation.
The Example requires the following dart runtime environment variables:
APP_ID
: Your Reclaim application IDAPP_SECRET
: Your application secretPROVIDER_ID
: The ID of the provider to verify against
You can provide these values using:
- Dart Define Env file:
--dart-define-from-file=./.env
- Hardcoded values (not recommended for production)
On android devices which don't have play services, you may get following errors in Android logs: java.lang.RuntimeException: All available Cronet providers are disabled. A provider should be enabled before it can be used.
, Google-Play-Services-Cronet-Provider is unavailable.
. This is because the Reclaim InApp SDK depends on cronet for making http requests.
To fix this, you need to use embedded cronet in your android app by adding the following dependency in your build.gradle dependencies block:
dependencies {
// ... other dependencies (not shown for brevity)
// Use embedded cronet
implementation("org.chromium.net:cronet-embedded:113.5672.61")
}
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT