▸ initializeSDK(): Future<bool>
Initializes the plugin using platform-specific configuration files (TransmitSecurity.plist on iOS, strings.xml values on Android). This is the recommended initialization approach.
Future<bool>
Indicates if initialization succeeded.
import 'package:flutter_ts_account_protection/flutter_ts_account_protection.dart';
final accountProtection = FlutterTsAccountProtection();
await accountProtection.initializeSDK();▸ initialize(clientId, baseUrl, {configuration, userId}): Future<bool>
Initializes the plugin with explicit parameters. Use this when you need to provide credentials programmatically instead of relying on platform configuration files.
| Name | Type | Description |
|---|---|---|
clientId | String | Your client identifier |
baseUrl | String | API base URL for your environment |
configuration | TSInitSDKConfiguration? | Optional configuration for location tracking |
userId | String? | Optional user ID to set during initialization |
Future<bool>
Indicates if initialization succeeded.
import 'package:flutter_ts_account_protection/flutter_ts_account_protection.dart';
final accountProtection = FlutterTsAccountProtection();
await accountProtection.initialize(
'YOUR_CLIENT_ID',
'https://api.transmitsecurity.io/risk-collect/',
configuration: TSInitSDKConfiguration(
enableLocationEvents: true,
),
userId: 'user-123',
);▸ triggerAction(action, {options, locationConfig, customAttributes}): Future<TSSetActionResponse>
Reports a user action event and returns an action token. The action token should be passed to your backend to fetch risk recommendations via the Recommendation API. This method does not throw on failure—check result.success and use result.actionToken when successful.
| Name | Type | Description |
|---|---|---|
action | String | The type of user action to report (use TSAction enum values) |
options | TSActionEventOptions? | Additional context for the action event |
locationConfig | TSLocationConfig? | Controls location data collection for this action (see Track geolocation) |
customAttributes | Map<String, dynamic>? | Additional contextual data for the action; must match the schema defined in the Portal (see Custom attributes) |
Future<TSSetActionResponse>
import 'package:flutter_ts_account_protection/flutter_ts_account_protection.dart';
final accountProtection = FlutterTsAccountProtection();
final response = await accountProtection.triggerAction(
TSAction.login.name,
options: TSActionEventOptions(
correlationId: 'CORRELATION_ID',
claimedUserId: '91e25bea0c...', // hashed email
claimedUserIdType: TSClaimedUserIdType.email,
referenceUserId: 'REFERENCE_USER_ID',
),
locationConfig: TSLocationConfig(mode: 'default'),
customAttributes: {'userLevel': 'premium'},
);
final actionToken = response.actionToken;▸ setAuthenticatedUser(userId, {options}): Future<bool>
Sets the user context for all subsequent events in the session (or until the user is explicitly cleared). It should be called only after you've fully authenticated the user (including, for example, any 2FA that was required). On Android, this call requires a foreground Activity—call it after the app UI is running, not during early startup.
| Name | Type | Description |
|---|---|---|
userId | String | Opaque identifier of the user in your system |
options | Map<String, dynamic>? | Optional user attributes |
Future<bool>
Indicates if the call succeeded.
import 'package:flutter_ts_account_protection/flutter_ts_account_protection.dart';
final accountProtection = FlutterTsAccountProtection();
await accountProtection.setAuthenticatedUser('user-123');▸ clearUser(): Future<bool>
Clears the user context for all subsequent events in the mobile session. The user is automatically cleared once the session expires or in case of a new login action.
Future<bool>
Indicates if the call succeeded.
import 'package:flutter_ts_account_protection/flutter_ts_account_protection.dart';
final accountProtection = FlutterTsAccountProtection();
await accountProtection.clearUser();▸ getSessionToken(): Future<String>
Returns a device session token that can be used to trigger action events via the Backend API. The session token binds user interactions to their device and is required for backend integrations. Call this after plugin initialization and before triggering events.
Future<String>
The session token.
import 'package:flutter_ts_account_protection/flutter_ts_account_protection.dart';
final accountProtection = FlutterTsAccountProtection();
final sessionToken = await accountProtection.getSessionToken();▸ logPageLoad(pageName): Future<bool>
Tracks screen navigation events for behavioral data collection. For automatic page-load tracking, use the built-in DrsCore.navigationObserver instead (see quick start). Use logPageLoad only if you need to report navigation events manually.
| Name | Type | Description |
|---|---|---|
pageName | String | The name of the screen or page the user navigated to |
Future<bool>
Indicates if the call succeeded.
import 'package:flutter_ts_account_protection/flutter_ts_account_protection.dart';
final accountProtection = FlutterTsAccountProtection();
await accountProtection.logPageLoad('LoginScreen');
await accountProtection.logPageLoad('Dashboard');▸ setLogLevel(isLogEnabled): Future<bool>
Enables or disables verbose plugin logging for debugging purposes.
| Name | Type | Description |
|---|---|---|
isLogEnabled | bool | Set to true to enable debug logging |
Future<bool>
Indicates if the call succeeded.
import 'package:flutter_ts_account_protection/flutter_ts_account_protection.dart';
final accountProtection = FlutterTsAccountProtection();
await accountProtection.setLogLevel(true); // Enable for debugging
await accountProtection.setLogLevel(false); // Disable for production