npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fingerprintjs/fingerprintjs-pro-react-native

v3.2.0

Published

Official React Native client for Fingerprint PRO. Best identification solution for React Native.

Downloads

16,198

Readme

Fingerprint Pro 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.

Table of contents

Requirements and limitations

  • 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.

Dependencies

How to install

1. Install the package using your favorite package manager:

  • 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

2. Configure native dependencies

  • iOS

    cd ios && pod install
  • Android

    Add a declaration of the Fingerprint Android repository to your app main build.gradle file to the allprojects section:

    maven {
      url("https://maven.fpregistry.io/releases")
    }
    maven {
      url("https://www.jitpack.io")
    }

    The file location is {rootDir}/android/build.gradle. After the changes the build.gradle file should look as following:

    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")
       }
       maven {
         url("https://www.jitpack.io")
       }
       google()
     }
    }

Usage

To identify visitors, you need a Fingerprint Pro account (you can sign up for free).

Hooks approach

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;

API Client approach

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 with hooks approach

  return (
    <FingerprintJsProProvider apiKey={PUBLIC_API_KEY} extendedResponseFormat={true}>
      <App />
    </FingerprintJsProProvider>
  )

Providing extendedResponseFormat with API Client approach

const FingerprintClient = new FingerprintJsProAgent({ apiKey: 'PUBLIC_API_KEY', region: 'eu', extendedResponseFormat: true }); // Region may be 'us', 'eu', or 'ap'
// =================================================================================================^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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.

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); 

API Reference

See the full generated API Reference.

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 [email protected].

License

This project is licensed under the MIT license.