fpjs_pro_plugin 4.0.0-test.1 copy "fpjs_pro_plugin: ^4.0.0-test.1" to clipboard
fpjs_pro_plugin: ^4.0.0-test.1 copied to clipboard

Flutter plugin that can be used in an application to call the native FingerprintJS Pro libraries and identify devices.

Build status Discord server

Fingerprint Pro Flutter #

Fingerprint is a device intelligence platform offering visitor identification and device intelligence with industry-leading accuracy. Fingerprint Flutter SDK is an easy way to integrate Fingerprint into your Flutter application. The plugin allows you to call the underlying native Fingerprint agents (Android, iOS, and Web) and identify devices.

Table of contents #

Requirements #

  • Flutter 3.13 or higher
  • Dart 3.3 or higher
  • Android 5.0 (API level 21+) or higher
  • iOS 13+/tvOS 15+, Swift 5.7 or higher (stable releases)

We aim to keep the Flutter compatibility policy.

Dependencies #

How to install #

Add fpjs_pro_plugin to the pubspec.yaml file in your Flutter app:

dependencies:
  flutter:
    sdk: flutter
  ...
  fpjs_pro_plugin: ^4.0.0-test.1
copied to clipboard

Run flutter pub get to download and install the package.

Web platform (Optional) #

To use this plugin on the web, add the JavaScript agent loader <script> tag to the <head> of your HTML template inside the web/index.html file:

<head>
  <!-- ... -->
  <script src="assets/packages/fpjs_pro_plugin/web/index.js" defer></script>
</head>
copied to clipboard

Usage #

To identify visitors, you need to sign up for a Fingerprint account (there is a free trial available).

1. Configure and initialize the plugin #

Initialize the Fingerprint Flutter plugin inside a StatefulWidget, for example, in the initState method.

Use the Public API key and region of your Fingerprint workspace (US region is used by default).

import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
import 'package:fpjs_pro_plugin/region.dart';

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

class MyApp extends StatefulWidget {
  @override
  State<MyApp> createState() => _MyAppState();
}

// Initialization
class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    doInit();
  }
  
  void doInit() async {
    await FpjsProPlugin.initFpjs(
      '<PUBLIC_API_KEY>', // insert your API key here
      region: Region.us // or Region.eu, Region.ap
    );
  }
  // ...
}
copied to clipboard

To avoid ad blockers, we recommend proxying requests from your application to Fingerprint servers through one of our proxy integrations. See Evading ad blockers with proxy integrations for more information.

To use a proxy integration, you can configure endpoint, scriptUrlPattern, and their fallbacks.

 void doInit() async {
    await FpjsProPlugin.initFpjs(
      '<PUBLIC_API_KEY>',
      region: Region.us,
      // Your proxy integration identification endpoint
      endpoint: 'https://metrics.yourwebsite.com',
      endpointFallbacks: ['https://api.fpjs.io'], // region-specific fallback
      // Your proxy integration script URL pattern
      // Only necessary for the web platform
      scriptUrlPattern: 'https://metrics.yourwebsite.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js',
      scriptUrlPatternFallbacks: [
        'https://fpjscdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js',
      ],
    );
  }
copied to clipboard

2. Identify visitors #

Use getVisitorId to get just the visitor ID, or getVisitorData to get the identification response object.

import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
import 'package:fpjs_pro_plugin/region.dart';
import 'package:fpjs_pro_plugin/error.dart';
// ...

class _MyAppState extends State<MyApp> {
  void identify() async {
    try {
      var visitorId = await FpjsProPlugin.getVisitorId();
      var visitorData = await FpjsProPlugin.getVisitorData();

      print('Visitor ID: $visitorId');
      print('Visitor data: $visitorData');
    } on FingerprintProError catch (e) {
      // Process the error
      print('Error identifying visitor: $e');
      // See lib/error.dart to get more information about error types
    }
  }
}
copied to clipboard

By default, getVisitorData() will return a short response (FingerprintJSProResponse). Pass extendedResponseFormat: true to the initFpjs function to get an extended response (FingerprintJSProExtendedResponse).

void doInit() async {
  await FpjsProPlugin.initFpjs('<PUBLIC_API_KEY>', extendedResponseFormat: true);
}
copied to clipboard

Linking and tagging information #

The visitorId provided by Fingerprint Identification is especially useful when combined with information you already know about your users, for example, account IDs, order IDs, etc. To learn more about various applications of the linkedId and tag, see Linking and tagging information.

void identify() async {
  const tags = {
    'userAction': 'login',
    'analyticsId': 'UA-5555-1111-1'
  };
  const linkedId = 'user_1234';

  visitorId = await FpjsProPlugin.getVisitorId(linkedId: linkedId, tags: tags);
  deviceData = await FpjsProPlugin.getVisitorData(linkedId: linkedId, tags: tags);
}
copied to clipboard

Specifying a custom timeout #

Default timeout value:

  • iOS: 60 seconds
  • Android: not specified
  • Web: 10 seconds

You can override the default timeout with a custom value of your choice. If the getVisitorId() or getVisitorData() call does not complete within the specified (or default) timeout, you will receive a ClientTimeoutError error.

void identify() async {
  visitorId = await FpjsProPlugin.getVisitorId(timeoutMs: 10000);
  deviceData = await FpjsProPlugin.getVisitorData(timeoutMs: 10000);
}
copied to clipboard

Additional Resources #

Support and feedback #

To report problems, ask questions, or provide feedback, please use Issues. If you need private support, please email us at oss-support@fingerprint.com.

License #

This project is licensed under the MIT license.

11
likes
150
points
4.46k
downloads

Publisher

verified publisherfingerprintjs.com

Weekly Downloads

2024.05.30 - 2025.04.24

Flutter plugin that can be used in an application to call the native FingerprintJS Pro libraries and identify devices.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on fpjs_pro_plugin