# @sparkfabrik/capacitor-plugin-idfa

> Get native IDFA or Advertising ID from iOS or Android device.

Latest version **5.0.0** (published 2023-05-30) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @sparkfabrik/capacitor-plugin-idfa
pnpm add @sparkfabrik/capacitor-plugin-idfa
yarn add @sparkfabrik/capacitor-plugin-idfa
bun add @sparkfabrik/capacitor-plugin-idfa
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2023-05-30 |
| First published | 2020-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Sparkfabrik |
| Maintainers | paolomainardi, monska85, edodusi |
| Keywords | capacitor, plugin, native, idfa, aaid, advertising, mobile |

## Links

- npm: https://www.npmjs.com/package/@sparkfabrik/capacitor-plugin-idfa
- Repository: https://github.com/sparkfabrik/capacitor-plugin-idfa
- Homepage: https://github.com/sparkfabrik/capacitor-plugin-idfa#readme
- Issues: https://github.com/sparkfabrik/capacitor-plugin-idfa/issues
- npm.io page: https://npm.io/package/@sparkfabrik/capacitor-plugin-idfa

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2023-05-30
- 4.0.3 — 2023-02-23
- 4.0.2 — 2023-01-20
- 4.0.1 — 2022-12-01
- 3.0.1 — 2021-08-17
- 1.0.4 — 2020-10-16
- 1.0.3 — 2020-10-16
- 1.0.2 — 2020-10-16
- 1.0.1 — 2020-10-16
- 1.0.0 — 2020-10-15

## README

# Capacitor plugin for getting Advertising ID (IDFA)

[![npm version](https://badge.fury.io/js/%40sparkfabrik%2Fcapacitor-plugin-idfa.svg)](https://badge.fury.io/js/%40sparkfabrik%2Fcapacitor-plugin-idfa)

## This plugin is deprecated! Please use [@capacitor-community/advertising-id](https://github.com/capacitor-community/advertising-id) instead.

## Index

- [Intro](#intro)
- [Supported platform](#supported-platform)
- [Installation](#installation)
- [Android configuration](#android-configuration)
- [iOS configuration](#ios-configuration)
- [Ionic configuration](#ionic-configuration)

## Intro

[Capacitor](https://capacitorjs.com/) provides a native mobile runtime and API layer for web apps. It allows mobile frontend frameworks (such as [Ionic Framework](https://ionicframework.com)) to access native device features.

The **Advertising Identifier** ([IDFA](https://developer.apple.com/documentation/adsupport/asidentifiermanager) on iOS, [AAID](https://developer.android.com/training/articles/ad-id) on Android) is a device-specific, unique, resettable ID for advertising that allows ddevelopers and marketers to track activity for advertising purposes.

This npm module allows any mobile application that uses Capacitor to access the Advertising ID, following the OS specific definition and user permissions.

The module output in the javascript framework is the following:

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

### Note

In version 2.0 we switched to Capacitor 3.0 and there are breaking changes, so if you are on Capacitor 2.x don't upgrade or just use version 1.x

## Supported platform

- Android
- iOS

_Note: the web version always returns null_

## Installation

`npm install @sparkfabrik/capacitor-plugin-idfa`

or

`yarn add @sparkfabrik/capacitor-plugin-idfa`

## Android configuration

_Nothing to add_

## iOS configuration

In `info.plist` make sure to add a description for the user permission request:

```xml
<key>NSUserTrackingUsageDescription</key>
<string>...</string>
```

## Ionic app implementation

### How to use the module in your own Ionic app

```ts
import {
  Idfa,
  AdvertisingInfoResponse,
} from '@sparkfabrik/capacitor-plugin-idfa';

// Get advertising id.
Idfa.getAdvertisingInfo()
  .then((response: AdvertisingInfoResponse) => {
    if (response.isAdTrackingLimited === true) {
      console.error('Ads tracking not allowed by user.');
    }
    console.log(response.id);
  })
  .catch((err: Error) => {
    console.error(err);
  });
```

---
_Source: https://npm.io/package/@sparkfabrik/capacitor-plugin-idfa · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
