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.
- 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
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.0Then run:
flutter pub getAdd 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
}
}Add to your android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />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:
| Environment | Base URL |
|---|---|
| US | https://api.transmitsecurity.io/risk-collect/ |
| EU | https://api.eu.transmitsecurity.io/risk-collect/ |
| Canada | https://api.ca.transmitsecurity.io/risk-collect/ |
| Australia | https://api.au.transmitsecurity.io/risk-collect/ |
| Custom domain | https://<your_custom_domain>/risk-collect/ |
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',
);| Parameter | Type | Required | Description |
|---|---|---|---|
clientId | String | Yes | Your client ID from the Admin Portal |
baseUrl | String | Yes | The base URL for your environment (see table above) |
configuration | TSInitSDKConfiguration? | No | Optional configuration object (see below) |
userId | String? | No | Set the user ID during initialization if already known |
Configuration options:
| Property | Type | Default | Description |
|---|---|---|---|
enableLocationEvents | bool | false | Enables 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). |
For a complete end-to-end integration walkthrough, see the Flutter plugin quick start.