A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/sparkfabrik/sparkfabrik-react-native-idfa-aaid below:

sparkfabrik/sparkfabrik-react-native-idfa-aaid: React Native module for getting IDFA (iOS) or AAID (Android)

@sparkfabrik/react-native-idfa-aaid

React Native module to get IDFA (iOS) or AAID (Android)

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

For native apps, in info.plist make sure to add:

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

For Expo apps, in app.json make sure to add:

{
  "expo": {
    "plugins": [
      [
        "expo-tracking-transparency",
        {
          "userTrackingPermission": "..."
        }
      ]
    ]
  }
}

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);
      });
  }, []);

In order to prevent a bug present in iOS 17.4 we also expose the getAdvertisingInfoAndCheckAuthorization(check: boolean) which aims to solve the problem of ATT Tracking Manager returning status denied even if the ATT modal was not yet displayed to the user.

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

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

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

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

MIT


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4