ios-tracking-transparency
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

ios-tracking-transparency

NPM

ios-tracking-transparency Capacitor plugin for ios tracking transparency

https://www.npmjs.com/package/ios-tracking-transparency

Install

npm install ios-tracking-transparency
yarn add ios-tracking-transparency
npx cap sync

API

	export type AuthorizationStatus =
	| 'authorized'
	| 'denied'
	| 'notDetermined'
	| 'restricted'
	| 'null';
	export interface AppTrackingTransparencyPlugin {
		requestTrackingAuthorization(): Promise<{
			status: AuthorizationStatus;
			code: number;
		}>;
		trackingAuthorizationStatus(): Promise<{
			status: AuthorizationStatus;
			code: number;
		}>;
	}

requestTrackingAuthorization()

	function requestTrackingAuthorization(): Promise<{
		status: AuthorizationStatus;
		code: number;
	}>;

trackingAuthorizationStatus()

	function trackingAuthorizationStatus(): Promise<{
		status: AuthorizationStatus;
		code: number;
	}>;

Snippet

import { AppTrackingTransparency } from 'ios-tracking-transparency';

function App(): JSX.Element {
    useEffect(() => {
        try {
            if (Capacitor.getPlatform() === 'ios') {
                AppTrackingTransparency.trackingAuthorizationStatus()
                    .then(async (trackStat) => {
                        if (trackStat.status !== 'authorized') {
                            await AppTrackingTransparency.requestTrackingAuthorization();
                        }
                    })
                    .catch((e) => console.warn('IOS Error', e));
            }
        } catch (e) {
            console.warn('Authorization failed', e);
        }
    }, []);
    return (
        <Components/>
    );
}

Xcode settings Info.plist

- Follow the guide below over Apple Dev to add the App Tracking key string in the info.plist file.

https://developer.apple.com/documentation/apptrackingtransparency

Readme

Keywords

Package Sidebar

Install

npm i ios-tracking-transparency

Weekly Downloads

777

Version

1.0.8

License

MIT

Unpacked Size

19.2 kB

Total Files

26

Last publish

Collaborators

  • codercodingthecode