Skip to content

p4u1d34n/capacitor-ios-app-tracking

 
 

Repository files navigation

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:

v0.1.1

  • Implemented iOS 14 IDFA AppTrackingTransparency.

Supported Platform:

  • iOS

Screenshots

iOS

Supported methods

Name
getTrackingStatus
requestPermission

Installation

Use Capacitor-IDFA-iOS-App-Tracking plugins in your app.

 npm install --save capacitor-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-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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 43.9%
  • TypeScript 23.4%
  • Ruby 15.5%
  • Objective-C 12.8%
  • JavaScript 4.4%