Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fingerprintjs/fingerprintjs-pro-flutter

A Flutter plugin for the native FingerprintJS Pro libraries
https://github.com/fingerprintjs/fingerprintjs-pro-flutter

dart fingerprint fingerprinting fingerprintjs fingerprintjs-pro flutter flutter-plugin fraud fraud-detection identification visitor-identifier

Last synced: 7 days ago
JSON representation

A Flutter plugin for the native FingerprintJS Pro libraries

Awesome Lists containing this project

README

        






Fingerprint logo




Build status


Discord server

# Fingerprint Pro Flutter
[Fingerprint](https://fingerprint.com/) is a device intelligence platform offering 99.5% accurate visitor
identification. Fingerprint Pro Flutter SDK is an easy way to integrate Fingerprint Pro into your Flutter
application to call the native Fingerprint Pro libraries (Android, iOS and Web) and identify devices.

## Table of contents
* [Requirements](#requirements)
* [Dependencies](#dependencies)
* [How to install](#how-to-install)
* [Usage](#usage)
* [Additional Resources](#additional-resources)
* [Support and feedback](#support-and-feedback)
* [License](#license)

## Requirements
- Flutter 3.10 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](https://docs.flutter.dev/release/compatibility-policy).

## Dependencies
- [Fingerprint Pro iOS](https://github.com/fingerprintjs/fingerprintjs-pro-ios)
- [Fingerprint Pro Android](https://github.com/fingerprintjs/fingerprintjs-pro-android)

## How to install
Add `fpjs_pro_plugin` to the pubspec.yaml in your Flutter app:

```yaml
dependencies:
flutter:
sdk: flutter
...
fpjs_pro_plugin: ^3.2.0
```

Run `pub get` to download and install the package.

### Web platform

Add a `` tag with the JS agent loader inside the `<head>` tag in your HTML template to use `fpjs_pro_plugin`:

```html
<script src="assets/packages/fpjs_pro_plugin/web/index.js" defer>
```

## Usage
To identify visitors, you need a Fingerprint Pro account (you can [sign up for free](https://dashboard.fingerprintjs.com/signup/)).

- Go to [the Fingerprint Pro dashboard](https://dashboard.fingerprint.com/).
- Navigate to **App Settings** > **API Keys** to find your _Public_ API Key.

### 1. Configure the plugin

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

// Initialization
class _MyAppState extends State {
@override
void initState() {
super.initState();
doInit();
}

void doInit() async {
await FpjsProPlugin.initFpjs(
'' // insert your actual API key here
);
}
// ...
}
```

You can also configure `region`, `endpoint` and `endpointFallbacks` in the `initFpjs` method, like below. For the web platform, you can use an additional `scriptUrlPattern` and `scriptUrlPatternFallbacks` properties to specify a custom URL for loading the JavaScript agent. This is required for proxy integrations.
```dart
void doInit() async {
await FpjsProPlugin.initFpjs(
'',
endpoint: 'https://subdomain.domain.com',
endpointFallbacks: ['https://subdomain2.domain.com', 'https://subdomain3.domain.com'],
region: Region.eu, // or Region.ap, Region.us
// Only necessary for the web platform
scriptUrlPattern: 'https://your.domain/fp_js/script_path?apiKey=&version=&loaderVersion=',
scriptUrlPatternFallbacks: ['https://your.second-domain/fp_js/script_path?apiKey=&version=&loaderVersion=']
);
}
```

### 2. Use the plugin in your application code to identify a visitor

#### 2.1 Use the `getVisitorId` method if you only need a `visitorId`:

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

// Initialization
class _MyAppState extends State {
// ...
// Usage
void identify() async {
try {
visitorId = await FpjsProPlugin.getVisitorId() ?? 'Unknown';
// use the visitor id
} on FingerprintProError catch (e) {
// process an error somehow
// check lib/error.dart to get more info about error types
}
}
}
```

#### 2.2 Use `getVisitorData` to get extended result

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

// Initialization
class _MyAppState extends State {
// ...
// Usage
void identify() async {
try {
deviceData = await FpjsProPlugin.getVisitorData();
// use the visitor id
} on FingerprintProError catch (e) {
// process an error somehow
// check lib/error.dart to get more info about error types
}
}
}
```

By default `getVisitorData()` will return a short response with the `FingerprintJSProResponse` type.
Provide `extendedResponseFormat=true` to the `initFpjs` function to get extended result of `FingerprintJSProExtendedResponse` type.

```dart
void doInit() async {
await FpjsProPlugin.initFpjs('', extendedResponseFormat: true);
}
```

### 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](https://dev.fingerprint.com/docs/tagging-information).

```dart
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);
}
```

## Additional Resources
- [Server-to-Server API](https://dev.fingerprint.com/docs/server-api)
- [Fingerprint Pro documentation](https://dev.fingerprint.com/docs)

## Support and feedback

To report problems, ask questions or provide feedback, please
use [Issues](https://github.com/fingerprintjs/fingerprintjs-pro-flutter/issues). If you need private support, please
email us at `[email protected]`.

## License
This project is licensed under the [MIT license](https://github.com/fingerprintjs/fingerprintjs-pro-flutter/blob/main/LICENSE).