ATT compliance React Native (iOS)

To adhere to Apple’s privacy guidelines and regulations, we refrain from tracking any data unless users have explicitly granted permission. This limitation applies solely to Firework's internal tracking systems.

Why does this limitation exist?

As required by Apple, third-party SDKs need to include the privacy manifest file containing the following infomation:

  1. The types of data collected by our SDK

  2. The required reasons APIs our SDK uses

  3. Tracking domains

With the presence of this privacy manifest, tracking requests to Firework tracking domains are prohibited by Apple unless users have explicitly granted their consent.

To enable Firework’s internal tracking on iOS, please utilize the AppTrackingTransparency framework to obtain users’ explicit consent. The steps are as follows:

  1. Add NSUserTrackingUsageDescription key and related value in Info.plist.

  2. Present an app-tracking authorization request to the user. The sample codes are:

func requestTrackingPermision() {
    if #available(iOS 14, *) {
        ATTrackingManager.requestTrackingAuthorization { status in
            switch status {
            case .authorized:
                debugPrint("ATT permission authorized")
            case .denied:
                debugPrint("ATT permission denied")
            case .notDetermined:
                debugPrint("ATT permission notDetermined")
            case .restricted:
                debugPrint("ATT permission restricted")
            @unknown default:
                break
            }
        }
    } else {}
}

override func application(
  _ application: UIApplication,
  didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
    FWFlutterSDK.initializeSDK(nil)
    // The following are merely sample codes.
    // You should invoke ATTrackingManager.requestTrackingAuthorization in accordance
    // with your business needs, such as executing it after
    // your app's home page is displayed.
    DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
        self.requestTrackingPermision()
    }
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

If your AppDelegate class is written by Objective-C, you should create a Swift file to call the API. For example, you could create FireworkSupportLibraryBridge.swift and add the following codes.

import Foundation
import FireworkVideo
import FireworkVideoIVSSupport

@objc
public class FireworkSupportLibraryBridge: NSObject {
    @objc public static func initFireworkSDK() {
        FWReactNativeSDK.initializeSDK(nil)
    }

    @objc public static func requestTrackingPermision() {
        if #available(iOS 14.5, *) {
            ATTrackingManager.requestTrackingAuthorization { status in
                switch status {
                case .authorized:
                    debugPrint("ATT permission authorized")
                case .denied:
                    debugPrint("ATT permission denied")
                case .notDetermined:
                    debugPrint("ATT permission notDetermined")
                case .restricted:
                    debugPrint("ATT permission restricted")
                @unknown default:
                    break
                }
            }
        } else {}
    }
}

Then add [FireworkSupportLibraryBridge requestTrackingPermision]; on application:didFinishLaunchingWithOptions: method.

// You should change the file to Objective-C Generated Interface Header name.
// Generally, it's "{TargetName}-Swift.h"
#import "FireworkSdkExample-Swift.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [FireworkSupportLibraryBridge initFireworkSDK];
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [FireworkSupportLibraryBridge requestTrackingPermision];
  });
  return YES;
}

For example, the users will see the following pop-up window for the first time.

The above are merely sample codes. You should invoke ATTrackingManager.requestTrackingAuthorization in accordance with your business needs, such as executing it after your app's home page is displayed.

For more details, please refer to the following links:

Last updated

Was this helpful?