This guide will help you set up and run the Verisoul Flutter Sample App, which demonstrates how to integrate Verisoul into a Flutter application.

About the Sample App

The Verisoul Flutter SDK is a demonstration project that showcases Verisoul’s fake user detection technology in a Flutter environment. The app includes:

  • Complete integration of Verisoul’s SDK for Flutter applications
  • Touch event tracking for both Android and iOS platforms
  • Cross-platform fraud detection capabilities

Prerequisites

Before you begin, you’ll need:

  • Flutter development environment set up
  • For Android: Android Studio and Android SDK
  • For iOS: Xcode and CocoaPods
  • A Verisoul Project ID (obtain this by scheduling a call)

Installation Steps

1. Add the Dependency

Add the Verisoul SDK to your project by updating your pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter
  # ... other dependencies
  verisoul_sdk: 0.1.0

Run the following command to install the dependencies:

flutter pub get

2. Android Configuration

Update Minimum SDK Version

Update the Android minimum SDK version to 24 in your android/app/build.gradle file:

defaultConfig {
    minSdk = 24
    // ... other configurations
}

Add Maven Repository (if needed)

If you encounter build issues with the ai.verisoul:android package, add this Maven repository to your android/build.gradle file:

allprojects {
    repositories {
        // ... existing repositories
        maven { url = uri("https://us-central1-maven.pkg.dev/verisoul/android") }
    }
}

3. iOS Configuration

Add App Attest Capability

To fully utilize Verisoul SDK on iOS:

  1. Open your iOS project in Xcode
  2. Add the App Attest capability to your project
  3. Update your app’s entitlements file:
    <key>com.apple.developer.devicecheck.appattest-environment</key>
    <string>production</string> <!-- or development -->
    

Add Privacy Manifest

Create a PrivacyInfo.xcprivacy file in your iOS project with the required privacy settings for device ID collection and system boot time API access.

4. Implementation

Initialize the SDK

Initialize the Verisoul SDK in your main.dart file:

import 'package:verisoul_sdk/verisoul.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  VerisoulSdk.configure(
    projectId: "YOUR_PROJECT_ID", 
    environment: VerisoulEnvironment.prod
  );
  runApp(const MyApp());
}

Get Session ID

Retrieve the session ID when needed:

final session = await VerisoulSdk.getSessionApi();
print("Session ID: $session");

Implement Touch Event Tracking

Add touch event tracking to your Flutter widgets:

GestureDetector(
  onPanDown: (event) {
    VerisoulSdk.touchEvent(
      x: event.localPosition.dx,
      y: event.localPosition.dy,
      action: MotionAction.down
    );
  },
  onPanEnd: (event) {
    VerisoulSdk.touchEvent(
      x: event.localPosition.dx,
      y: event.localPosition.dy,
      action: MotionAction.up
    );
  },
  onPanUpdate: (event) {
    VerisoulSdk.touchEvent(
      x: event.localPosition.dx,
      y: event.localPosition.dy,
      action: MotionAction.move
    );
  },
  child: // Your widget here
)

5. Platform-Specific Setup

Android Touch Events

For Android, modify your MainActivity.kt file to track touch events:

import ai.verisoul.sdk.Verisoul
import android.view.MotionEvent

class MainActivity: FlutterActivity() {
  override fun onTouchEvent(event: MotionEvent?): Boolean {
    Verisoul.onTouchEvent(event)
    return super.onTouchEvent(event)
  }
}

What to Expect

Once integrated, the Verisoul Flutter SDK will:

  • Collect touch events and device motion data on both Android and iOS
  • Generate a session ID for risk assessment
  • Upload necessary data to Verisoul’s backend
  • Provide cross-platform fraud detection for your Flutter application

Next Steps

After exploring the sample app, you can use it as a reference for implementing Verisoul in your own Flutter applications.

For more detailed documentation, see the Verisoul Integration Guide.