Capacitor plugin for ios tracking transparency
https://www.npmjs.com/package/ios-tracking-transparency
npm install ios-tracking-transparency
yarn add ios-tracking-transparency
npx cap sync
export type AuthorizationStatus =
| 'authorized'
| 'denied'
| 'notDetermined'
| 'restricted'
| 'null';
export interface AppTrackingTransparencyPlugin {
requestTrackingAuthorization(): Promise<{
status: AuthorizationStatus;
code: number;
}>;
trackingAuthorizationStatus(): Promise<{
status: AuthorizationStatus;
code: number;
}>;
}
function requestTrackingAuthorization(): Promise<{
status: AuthorizationStatus;
code: number;
}>;
function trackingAuthorizationStatus(): Promise<{
status: AuthorizationStatus;
code: number;
}>;
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/>
);
}
- 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