Git Product home page Git Product logo

sparkfabrik-react-native-idfa-aaid's Introduction

@sparkfabrik/react-native-idfa-aaid

React Native module for getting IDFA (iOS) or AAID (Android)

Intro

React Native is a framework for creating native mobile apps based on React.

The Advertising Identifier (IDFA on iOS, AAID on Android) is a device-specific, unique, resettable ID for advertising that allows developers and marketers to track activity for advertising purposes.

This npm module allows any mobile application built with React Native to access the Advertising ID, following the OS specific definition and user permissions.

The module output in the RN framework is the following:

interface AdvertisingInfoResponse {
  id: string; // the Advertising ID (or null if not defined/permitted)
  isAdTrackingLimited: boolean; // the user defined permission to track
}

Supported platform

  • Android
  • iOS

Installation

npm install @sparkfabrik/react-native-idfa-aaid

or

yarn add @sparkfabrik/react-native-idfa-aaid

Then run pod install in your ios folder after installation.

Usage

iOS configuration

In info.plist make sure to add:

<key>NSUserTrackingUsageDescription</key>
<string>...</string>

React Native components

Example of a basic integration in a RN component.

import ReactNativeIdfaAaid, { AdvertisingInfoResponse } from '@sparkfabrik/react-native-idfa-aaid';

const MyComponent: React.FC = () => {
  const [idfa, setIdfa] = useState<string | null>();

  useEffect(() => {
    ReactNativeIdfaAaid.getAdvertisingInfo()
      .then((res: AdvertisingInfoResponse) =>
        !res.isAdTrackingLimited ? setIdfa(res.id) : setIdfa(null),
      )
      .catch((err) => {
        console.log(err);
        return setIdfa(null);
      });
  }, []);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

sparkfabrik-react-native-idfa-aaid's People

Contributors

edodusi avatar phongsa avatar dependabot[bot] avatar nazrdogan avatar raphaelrk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.