Capacitor-IDFA-iOS-App-Tracking is a native AppTrackingTransparency implementation for iOS 14. Now you can use this package as a Ionic Capacitor Plugin in your App.
- Implemented iOS 14 IDFA AppTrackingTransparency.
- iOS
| iOS |
| Name |
|---|
| getTrackingStatus |
| requestPermission |
Use Capacitor-IDFA-iOS-App-Tracking plugins in your app.
npm install --save capacitor-ios-app-tracking
ionic cap updateOpen your App/App/Info.plist file and add this plist value line at the right spot (and replace the value with the message for the user!):
<key>NSUserTrackingUsageDescription</key>
<!-- replace this value with your message-->
<string>Message to Users.</string>import React, { useEffect } from "react"
import { Plugins } from "@capacitor/core";
import { Response } from 'capacitor-ios-app-tracking'
const { IOSAppTracking } = Plugins;
const App: React.FC = () => {
const [ response, setResponse ] = useState<Response>()
useEffect(() => {
IOSAppTracking.getTrackingStatus().then((res: Response ) => setResponse(res))
}, [])
useEffect(() => {
if(response.status === 'unrequested') {
IOSAppTracking.requestPermission().then((res: Response) => console.log(res))
}
}, [response])
...
}IOSAppTracking.getTrackingStatus().then((res: Response ) => console.log(res))IOSAppTracking.requestPermission().then((res: Response) => console.log(res))interface Response {
value: string;
status: Status;
}type Status = 'authorized' | 'denied' | 'unrequested' | 'restricted' Capacitor-IDFA-iOS-App-Tracking is MIT licensed.