fpjs_pro_plugin 3.3.2 fpjs_pro_plugin: ^3.3.2 copied to clipboard
Flutter plugin that can be used in an application to call the native FingerprintJS Pro libraries and identify devices.
Fingerprint Pro Flutter #
Fingerprint 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 #
- 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.
Dependencies #
How to install #
Add fpjs_pro_plugin
to the pubspec.yaml in your Flutter app:
dependencies:
flutter:
sdk: flutter
...
fpjs_pro_plugin: ^3.3.2
Run pub get
to download and install the package.
Web platform #
Add a <script>
tag with the JS agent loader inside the <head>
tag in your HTML template to use fpjs_pro_plugin
:
<script src="assets/packages/fpjs_pro_plugin/web/index.js" defer></script>
Usage #
To identify visitors, you need a Fingerprint Pro account (you can sign up for free).
- Go to the Fingerprint Pro dashboard.
- Navigate to App Settings > API Keys to find your Public API Key.
1. Configure the plugin #
import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
// ...
// Initialization
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
doInit();
}
void doInit() async {
await FpjsProPlugin.initFpjs(
'<apiKey>' // 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.
void doInit() async {
await FpjsProPlugin.initFpjs(
'<apiKey>',
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=<apiKey>&version=<version>&loaderVersion=<loaderVersion>',
scriptUrlPatternFallbacks: ['https://your.second-domain/fp_js/script_path?apiKey=<apiKey>&version=<version>&loaderVersion=<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
:
import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
// ...
// Initialization
class _MyAppState extends State<MyApp> {
// ...
// 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
import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
// ...
// Initialization
class _MyAppState extends State<MyApp> {
// ...
// 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.
void doInit() async {
await FpjsProPlugin.initFpjs('<apiKey>', 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.
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);
}
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);
}
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.