Incognia for Flutter

The flutter plugin for Incognia mobile SDKs.

Getting Started

The Incognia mobile SDK captures device information, location-related signals (GPS, Wi-Fi), and user sessions to help differentiate attackers from legit users. To gather risk assessment from the APIs, start by installing and configuring the mobile SDK.

Installation

To install the Incognia Flutter plugin, add the following dependency to your pubspec.yaml file:

dependencies:
  incognia_flutter: ^1.1.1

Configuration

To configure you need to set platform-specific configurations.

Android

Update Android manifest

Add the following <uses-permission> tags inside the <manifest> tag of your AndroidManifest.xml file.

<manifest>
  <!-- Required for connectivity access -->
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

  <!-- Required for location services -->
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>

There are a few optional permissions that the SDK may also use if available. If you are interested, more explanation about the manifest permissions can be found on our flutter documentation.

Add Incognia's config file to your project

The Incognia SDK initialization relies on the presence of a incognia.xml file in the main/res/values directory of your Android project. To access the configuration file, go to Incognia dashboard and download it.

The config properties semantics are explained on our flutter documentation.

iOS

Capabilities

The Incognia SDK uses the Access WiFi Information capability to improve visit detection and location accuracy. To allow it, in the Capabilities section of your Runner on XCode, enable the Access WiFi Information capability (XCode 10 and iOS 12+ only).

Add Incognia's config file to your project

The Incognia SDK initialization relies on the presence of an IncogniaOptions.plist file in your project. To access the configuration file, go to Incognia dashboard and download it. Make sure you have the Flutter Runner and other relevant targets selected.

Initializing the SDK

It is recommended to initialize the SDK at the earliest point in your app lifecycle. You can do that by overriding the initState method of your StatefulWidget state, like the example below shows:

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _incogniaFlutterPlugin = IncogniaFlutter();

  @override
  void initState() {
    super.initState();
    _incogniaFlutterPlugin.initSdk();
  }
}