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

cordova-plugin-idfaiosx

v2.0.0

Published

Cordova plugin for getting Advertising ID (IDFA or AAID)

Downloads

7

Readme

Cordova plugin for getting Advertising ID (IDFA or AAID)

Index

Supported Platforms

  • iOS

Installation

$ cordova plugin add cordova-plugin-idfaiosx

API

The API is available on the cordova.plugins.idfa global object.

getInfo()

Returns a Promise<object> with the following fields:

  • trackingLimited: boolean - Whether usage of advertising id is allowed by user.
  • idfa: string (iOS only) - Identifier for advertisers.
  • trackingPermission (iOS 14+ only): number Tracking permission status, available on iOS 14+ devices.

requestPermission()

(iOS only) A one-time request to authorize or deny access to app-related data that can be used for tracking the user or the device. See Apple's API docs for more info on the dialog presented to the user. Available only for iOS 14+ devices.

Returns a Promise<number>. On devices with iOS < 14 the method will return a rejected promise.

Note: You should make sure to set the NSUserTrackingUsageDescription key in your app's Information Property List file, otherwise your app will crash when you use this API. You can do it with the following code in your Cordova project's config.xml:

<platform name="ios">
    <edit-config target="NSUserTrackingUsageDescription" file="*-Info.plist" mode="merge">
        <string>My tracking usage description</string>
    </edit-config>
</platform>

Tracking Permission Values

The tracking permission values are numbers returned by getInfo() and requestPermission(). The possible values are stored in constants on the plugin object. See the example on how to use them.

For the meaning of the values see the tracking transparency API docs:

| Constant | Value | Description | | :--------------------------------- | :---- | :-------------------------------------------------------------------------------------------------------- | | TRACKING_PERMISSION_NOT_DETERMINED | 0 | User has not yet received an authorization request to authorize access to IDFA | | TRACKING_PERMISSION_RESTRICTED | 1 | User restricted the value returned if authorization to access IDFA | | TRACKING_PERMISSION_DENIED | 2 | The value returned if the user denies authorization to access IDFA | | TRACKING_PERMISSION_AUTHORIZED | 3 | The value returned if the user authorizes access to IDFA |

Example

const idfaPlugin = cordova.plugins.idfa;

idfaPlugin.getInfo()
    .then(info => {
        if (!info.trackingLimited) {
            return info.idfa || info.aaid;
        } else if (info.trackingPermission === idfaPlugin.TRACKING_PERMISSION_NOT_DETERMINED) {
            return idfaPlugin.requestPermission().then(result => {
                if (result === idfaPlugin.TRACKING_PERMISSION_AUTHORIZED) {
                    return idfaPlugin.getInfo().then(info => {
                        return info.idfa || info.aaid;
                    });
                }
            });
        }
    })
    .then(idfaOrAaid => {
        if (idfaOrAaid) {
            console.log(idfaOrAaid);
        }
    });