✨Works out of the box guarantee. If you face any issue at all, hit us up on Telegram and we will write the integration for you.

Flutter
Advanced Configurations

Advanced Configuration of the Reclaim Protocol Flutter SDK

This guide covers advanced configuration options for the Reclaim Protocol Flutter SDK, allowing you to customize your integration for specific use cases.

Ensure you're familiar with the Flutter example before exploring these advanced options. Make sure to use advanced configuration options before calling getRequestUrl().

Advanced Options

Adding Context

The addContext method allows you to add additional information to your proof request. This context is reflected in the proof object, helping to identify and distinguish between different proof requests.

final reclaimProofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID', // Replace with your actual Reclaim app ID
  'YOUR_RECLAIM_APP_SECRET', // Replace with your actual Reclaim app secret
  'YOUR_PROVIDER_ID' // Replace with your actual provider ID
);
 
reclaimProofRequest.addContext('0x1234567890abcdef', 'User registration proof'); 
 
final requestUrl = await reclaimProofRequest.getRequestUrl();
  • contextId: A unique identifier for the context (hex address)
  • Context message: Additional information about the proof request (string)

Use context to provide helpful metadata about your proof request, such as its purpose or origin. This is especially useful when handling multiple types of proofs. Remember to use a valid hex address for the contextId, starting with '0x' and containing only hexadecimal characters (0-9 and a-f).

Setting Parameters

The setParams method allows you to set specific conditions that must be met for the proof to be generated. This is useful for selective triggering and manual verification flows.

final reclaimProofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID', // Replace with your actual Reclaim app ID
  'YOUR_RECLAIM_APP_SECRET', // Replace with your actual Reclaim app secret
  'YOUR_PROVIDER_ID' // Replace with your actual provider ID
);
 
reclaimProofRequest.setParams({
  'minConnections': '500', // Value must be a string
  'industry': 'Technology' // Value must be a string
});
 
final requestUrl = await reclaimProofRequest.getRequestUrl();

Use this option carefully. If the actual data doesn't match the set parameters, proof generation will not trigger. Ensure that the parameters you set are achievable and relevant to the proof you're requesting.

Custom Redirect URL

The setRedirectUrl method allows you to specify a custom URL where users will be redirected after the verification process. You can use this to set up a deep link to your app, ensuring a seamless return to your application after proof generation.

final reclaimProofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID', // Replace with your actual Reclaim app ID
  'YOUR_RECLAIM_APP_SECRET', // Replace with your actual Reclaim app secret
  'YOUR_PROVIDER_ID' // Replace with your actual provider ID
);
 
// Set a deep link URL for your app
reclaimProofRequest.setRedirectUrl('yourapp://verification-complete');
 
final requestUrl = await reclaimProofRequest.getRequestUrl();

To set up deep linking in your Flutter app:

  1. Configure your app to handle the custom URL scheme (e.g., 'yourapp://')
  2. Set up a route in your app to handle the '/verification-complete' path
  3. Process any additional data passed through the deep link as needed

For a complete guide on deep linking in Flutter, see: Deep Linking in Flutter (opens in a new tab)

Custom Callback URL

The setAppCallbackUrl method allows you to specify a custom API endpoint where proofs will be sent upon successful generation.

final reclaimProofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID', // Replace with your actual Reclaim app ID
  'YOUR_RECLAIM_APP_SECRET', // Replace with your actual Reclaim app secret
  'YOUR_PROVIDER_ID' // Replace with your actual provider ID
);
 
reclaimProofRequest.setAppCallbackUrl('https://your-api.com/receive-proofs');
 
final requestUrl = await reclaimProofRequest.getRequestUrl();

This method is particularly useful for backend implementations. It allows you to receive proofs directly without polling the status URL. Ensure your endpoint is secure and can handle incoming proof data.

Exporting and Importing SDK Configuration

The SDK provides methods to export and import the entire configuration as a JSON string. This allows for flexible usage across different parts of your application.

// Export configuration
final reclaimProofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID', // Replace with your actual Reclaim app ID
  'YOUR_RECLAIM_APP_SECRET', // Replace with your actual Reclaim app secret
  'YOUR_PROVIDER_ID' // Replace with your actual provider ID
);
 
final reclaimProofRequestConfig = reclaimProofRequest.toJsonString();
 
// On a different service or application import the configuration
final reclaimProofRequest = await ReclaimProofRequest.fromJsonString(reclaimProofRequestConfig);
final requestUrl = await reclaimProofRequest.getRequestUrl();

This feature is particularly useful when you need to initialize the SDK in one part of your application (e.g., frontend) and use it in another (e.g., backend). It provides a seamless way to transfer the configuration.

Initialization Options

When initializing the SDK, you can pass additional options to customize its behavior:

import 'package:reclaim_sdk/utils/types.dart';
import 'package:reclaim_sdk/reclaim.dart';
 
final proofRequest = await ReclaimProofRequest.init(
  'YOUR_RECLAIM_APP_ID', // Replace with your actual Reclaim app ID
  'YOUR_RECLAIM_APP_SECRET', // Replace with your actual Reclaim app secret
  'YOUR_PROVIDER_ID', // Replace with your actual provider ID
  ProofRequestOptions(log: true)
);
  • log: When set to true, enables detailed logging for debugging purposes.

Use this option to enhance debugging capabilities in your application. The logging option is particularly useful during development and testing phases.

Best Practices for Advanced Configuration

  1. Security: Always prioritize security when configuring callbacks and parameters. Use HTTPS for all URLs and avoid passing sensitive data in parameters.

  2. Error Handling: Implement robust error handling for all advanced configurations, especially when dealing with callbacks and redirects.

  3. Testing: Thoroughly test your advanced configurations in a staging environment before deploying to production.

  4. Documentation: Maintain clear documentation of your custom configurations, especially when using context or custom parameters.

Remember, while these advanced configurations offer more flexibility, they also require careful implementation to ensure security and reliability.

By leveraging these advanced configuration options, you can create a more tailored and robust integration of the Reclaim Protocol into your Flutter application. If you have any questions about these advanced features, don't hesitate to reach out to our support team or community forums.

Happy coding with Reclaim Protocol!