This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@sparkfabrik/capacitor-plugin-idfa
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

Capacitor plugin for getting Advertising ID (IDFA)

npm version

This plugin is deprecated! Please use @capacitor-community/advertising-id instead.

Index

Intro

Capacitor provides a native mobile runtime and API layer for web apps. It allows mobile frontend frameworks (such as Ionic Framework) to access native device features.

The Advertising Identifier (IDFA on iOS, AAID 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:

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:

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

Ionic app implementation

How to use the module in your own Ionic app

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

Package Sidebar

Install

npm i @sparkfabrik/capacitor-plugin-idfa

Weekly Downloads

133

Version

5.0.0

License

MIT

Unpacked Size

9.04 MB

Total Files

107

Last publish

Collaborators

  • giulio.bracci
  • paolomainardi
  • monska85
  • edodusi