Skip to content

The flutter_ts_account_protection is a Flutter plugin for Mosaic Fraud Prevention on Android and iOS.

When initialized, the plugin automatically starts collecting and submitting telemetry data to Mosaic—including information about the user journey, device data, and user interactions. Once specific user actions are performed on the client side (such as login), Fraud Prevention should be called to track those action events and obtain action tokens. The data collected can then be queried for recommendations using the Recommendations backend API.

Requirements

  • Flutter 3.0.0 or higher
  • iOS 13.0 or higher
  • Android API level 24 (Android 7.0) or higher
  • Dart 2.17.0 or higher

Installation

Add the plugin to your pubspec.yaml:

dependencies:
  flutter_ts_account_protection:
    git:
      url: https://github.com/TransmitSecurity/flutter_ts_account_protection.git
      ref: 1.0.0

Then run:

flutter pub get

Platform configuration

build.gradle

Add the Transmit Security Maven repository to your module-level android/build.gradle:

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://transmit.jfrog.io/artifactory/transmit-security-gradle-release-local/"
        }
    }
}

In your android/app/build.gradle, set the minimum SDK version:

android {
    compileSdkVersion 34
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 34
    }
}

AndroidManifest.xml

Add to your android/app/src/main/AndroidManifest.xml:

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

strings.xml

Update your strings.xml file with your credentials:

<resources>
    <string name="transmit_security_client_id">"CLIENT_ID"</string>
    <string name="transmit_security_base_url">https://api.transmitsecurity.io/risk-collect/</string>
</resources>

Use the appropriate base URL for your environment:

EnvironmentBase URL
UShttps://api.transmitsecurity.io/risk-collect/
EUhttps://api.eu.transmitsecurity.io/risk-collect/
Canadahttps://api.ca.transmitsecurity.io/risk-collect/
Australiahttps://api.au.transmitsecurity.io/risk-collect/
Custom domainhttps://<your_custom_domain>/risk-collect/

Initialization

Import the package and create an instance of the plugin:

import 'package:flutter_ts_account_protection/flutter_ts_account_protection.dart';

final accountProtection = FlutterTsAccountProtection();

Simple initialization (using platform configuration files):

await accountProtection.initializeSDK();

With explicit parameters:

await accountProtection.initialize(
  'YOUR_CLIENT_ID',
  'https://api.transmitsecurity.io/risk-collect/',
  configuration: TSInitSDKConfiguration(
    enableLocationEvents: true,
  ),
  userId: 'optional-user-id',
);

initialize parameters

ParameterTypeRequiredDescription
clientIdStringYesYour client ID from the Admin Portal
baseUrlStringYesThe base URL for your environment (see table above)
configurationTSInitSDKConfiguration?NoOptional configuration object (see below)
userIdString?NoSet the user ID during initialization if already known

Configuration options:

PropertyTypeDefaultDescription
enableLocationEventsboolfalseEnables reporting device location during plugin initialization and when the app moves to the foreground. The user must consent to sharing location in advance (see Track geolocation).

Next steps

For a complete end-to-end integration walkthrough, see the Flutter plugin quick start.