
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@fingerprintjs/fingerprintjs-pro-react-native
Advanced tools
Official React Native client for Fingerprint PRO. Best identification solution for React Native.
Fingerprint is a device intelligence platform offering 99.5% accurate visitor identification. Fingerprint Pro React Native SDK is an easy way to integrate Fingerprint Pro into your React Native application to call the native Fingerprint Pro libraries (Android and iOS) and identify devices.
React Native 0.73 or higher
Android 5.0 (API level 21+) or higher
iOS 13+/tvOS 15+, Swift 5.7 or higher (stable releases)
Fingerprint Pro request filtering is not supported right now. Allowed and forbidden origins cannot be used.
Usage inside the Expo environment is not supported right now.
NPM:
npm install @fingerprintjs/fingerprintjs-pro-react-native --save
Yarn:
yarn add @fingerprintjs/fingerprintjs-pro-react-native
PNPM:
pnpm add @fingerprintjs/fingerprintjs-pro-react-native
cd ios && pod install
To declare the Fingerprint Maven repository, add the following declarations:
maven {
url("https://maven.fpregistry.io/releases")
}
Add the repositories to your Gradle configuration file. The location for these additions depends on your project's structure and the Gradle version you're using:
For Gradle versions before 7.0, you likely have an allprojects
block in {rootDir}/android/build.gradle
. Add the Maven repositories within this block:
allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
maven {
url("https://maven.fpregistry.io/releases") // Add this
}
google()
}
}
For Gradle 7.0 and higher (if you've adopted the new Gradle settings file approach), you likely manage repositories in the dependencyResolutionManagement
block in {rootDir}/android/settings.gradle
. Add the Maven repositories in this block:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
maven {
url("https://maven.fpregistry.io/releases") // Add this
}
}
}
To identify visitors, you need a Fingerprint Pro account (you can sign up for free).
Configure the SDK by wrapping your application in FingerprintJsProProvider.
// src/index.js
import React from 'react';
import { AppRegistry } from 'react-native';
import { FingerprintJsProProvider } from '@fingerprintjs/fingerprintjs-pro-react-native';
import App from './App';
const WrappedApp = () => (
<FingerprintJsProProvider
apiKey={'your-fpjs-public-api-key'}
region={'eu'}
>
<App />
</FingerprintJsProProvider>
);
AppRegistry.registerComponent('AppName', () => WrappedApp);
Use the useVisitorData
hook in your components to perform visitor identification and get the data.
// src/App.js
import React, { useEffect } from 'react';
import { Text } from 'react-native';
import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react-native';
function App() {
const {
isLoading,
error,
data,
getData,
} = useVisitorData();
useEffect(() => {
getData();
}, []);
if (isLoading) {
return <Text>Loading...</Text>;
}
if (error) {
return <Text>An error occured: {error.message}</Text>;
}
if (data) {
// perform some logic based on the visitor data
return (
<Text>
Visitor id is {data.visitorId}
</Text>
);
} else {
return null;
}
}
export default App;
import React, { useEffect } from 'react';
import { FingerprintJsProAgent } from '@fingerprintjs/fingerprintjs-pro-react-native';
// ...
useEffect(() => {
async function getVisitorInfo() {
try {
const FingerprintClient = new FingerprintJsProAgent({ apiKey: 'PUBLIC_API_KEY', region: 'eu' }); // Region may be 'us', 'eu', or 'ap'
const visitorId = await FingerprintClient.getVisitorId(); // Use this method if you need only visitorId
const visitorData = await FingerprintClient.getVisitorData(); // Use this method if you need additional information about visitor
// use visitor data in your code
} catch (e) {
console.error('Error: ', e);
}
}
getVisitorInfo();
}, []);
extendedResponseFormat
Two types of responses are supported: "default" and "extended". You don't need to pass any parameters to get the "default" response.
"Extended" is an extended result format that includes geolocation, incognito mode and other information.
It can be requested using the extendedResponseFormat
: true parameter. See more details about the responses in the documentation.
Providing extendedResponseFormat
using hooks:
return (
<FingerprintJsProProvider apiKey={PUBLIC_API_KEY} extendedResponseFormat={true}>
<App />
</FingerprintJsProProvider>
)
Providing extendedResponseFormat
using the API Client:
const FingerprintClient = new FingerprintJsProAgent({ apiKey: 'PUBLIC_API_KEY', region: 'eu', extendedResponseFormat: true }); // Region may be 'us', 'eu', or 'ap'
// =================================================================================================^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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.
const tag = {
userAction: 'login',
analyticsId: 'UA-5555-1111-1'
};
const linkedId = 'user_1234';
// Using hooks
const { getData } = useVisitorData();
const visitorData = await getData(tag, linkedId);
// Using the client
const FingerprintClient = new FingerprintJsProAgent({ apiKey: 'PUBLIC_API_KEY'});
const visitorId = await FingerprintClient.getVisitorId(tag, linkedId);
const visitor = await FingerprintClient.getVisitorData(tag, linkedId);
See the full generated API Reference.
To report problems, ask questions or provide feedback, please
use Issues. If you need private support,
please email us at oss-support@fingerprint.com
.
This project is licensed under the MIT license.
FAQs
Official React Native client for Fingerprint PRO. Best identification solution for React Native.
The npm package @fingerprintjs/fingerprintjs-pro-react-native receives a total of 2,087 weekly downloads. As such, @fingerprintjs/fingerprintjs-pro-react-native popularity was classified as popular.
We found that @fingerprintjs/fingerprintjs-pro-react-native demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.