App Tracking Transparency with the Native SDK for iOS

In this topic, you will learn how to manage user privacy and data use with the Brightcove Native SDK for iOS.

Introduction

With iOS 14.5, there is a new privacy feature called App Tracking Transparency. You can use this feature in your apps to request tracking permission from your users. When users say no to tracking, the app will not be able to use Apple's ID for Advertisers (IDFA) or other identifiers, like hashed email addresses, to share data about their activity for ad-targeting.

If your app collects end-user data and shares it with other companies for tracking purposes across apps and web sites, then you must use the AppTrackingTransparency framework.

For details, see the following:

Requirements

The following requirements are needed for App Tracking Transparency:

Platform

Here are the system requirements:

  • iOS or tvOS version 14.5 or newer

Brightcove Native SDK

It is recommended to use the latest version of the Native SDK.

  • Native SDK for iOS or tvOS version 6.8.0 or newer
  • For details, see the SDK release notes

Prompt users about IDFA sharing

The sample apps mentioned below show how to display the App Tracking Transparency alert to determine if your app can use the ID for Advertisers (IDFA) or not.

  1. Open and review either of the following sample apps:

  2. Open BaseViewController.swift in IMA/BasicIMAPlayer-iOS or ViewController.swift in Pulse/BasicPulsePlayer-iOS. The IMA sample requests authorization in viewDidLoad; the Pulse sample also retries on UIApplication.didBecomeActiveNotification when the status is not determined.
  3. The samples check ATTrackingManager.trackingAuthorizationStatus and request authorization with ATTrackingManager.requestTrackingAuthorization. The SDK uses IDFA only when the returned status is .authorized. This Swift helper illustrates the flow. Call it while the app is active, and load ads in the completion handler whether permission is granted or denied.

    import AppTrackingTransparency
    
    // Call from an active app, before requesting ads.
    func requestTrackingPermission(completion: @escaping () -> Void) {
      if #available(iOS 14.5, tvOS 14.5, *) {
        if ATTrackingManager.trackingAuthorizationStatus == .notDetermined {
          ATTrackingManager.requestTrackingAuthorization { status in
            // Only .authorized permits access to IDFA. Continue without it otherwise.
            DispatchQueue.main.async {
              completion()
            }
          }
        } else {
          completion()
        }
      } else {
        completion()
      }
    }
  4. For older iOS versions, the SDK uses the value of ASIdentifierManager.sharedManager.isAdvertisingTrackingEnabled to determine if the IDFA should be used.