1.0.2 • Published 4 years ago
capacitor-idfa-ios-app-tracking v1.0.2
Capacitor-iOS-IDFA-App-Tracking
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.
Release Note:
v1.0.2
- Implemented iOS 14 IDFA AppTrackingTransparency.
Supported Platform:
- iOS
Supported methods
Name |
---|
getTrackingStatus |
requestPermission |
Installation
Use Capacitor-IDFA-iOS-App-Tracking plugins in your app.
npm install --save capacitor-idfa-ios-app-tracking
ionic cap update
iOS
Update Info.plist
Open 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>
Example
import React, { useEffect } from "react"
import { Plugins } from "@capacitor/core";
import { Response } from 'capacitor-idfa-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])
...
}
getTrackingStatus()
IOSAppTracking.getTrackingStatus().then((res: Response ) => console.log(res))
requestPermission()
IOSAppTracking.requestPermission().then((res: Response) => console.log(res))
Response
interface Response {
value: string;
status: Status;
}
Status
type Status = 'authorized' | 'denied' | 'unrequested' | 'restricted'
License
Capacitor-IDFA-iOS-App-Tracking is MIT licensed.