paint-brush
How To Integrate App Tracking Transparency with your iOS Unity Projectby@cambytebrew
976 reads
976 reads

How To Integrate App Tracking Transparency with your iOS Unity Project

by ByteBrewApril 5th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

ByteBrew is the all-in-one mobile game growth platform built by Game Devs for game developers. The ByteBrew SDK covers your iOS 14 compliant bases by integrating our custom App Tracking Transparency handler into your Unity iOS project for your ATT-dependent SDK's without having to write any Objective-C code. ByteBrew also comes with our free analytic and remote config tools for all developers to use in their games. This article was written by Cameron Houri, the founder of ByteBrew.
featured image - How To Integrate App Tracking Transparency with your iOS Unity Project
ByteBrew HackerNoon profile picture

This tutorial is here to help all unity mobile developers through the complex environment of iOS 14’s new privacy changes (aka. App Tracking Transparency Consent, IDFA depreciation, etc.). In the new world of post-iOS 14 announcement, almost all ad-based SDK’s are requiring developers to automatically call the App Tracking Transparency Consent prompt prior to initializing their SDK’s.

This poses a major issue for developers that have no idea how to code in Objective-C or build libraries to communicate with Unity. Since ByteBrew's vision has always been to support the game developer community we were a part of, we built an easy-to-implement SDK to solve the issue.

ByteSyze SDK covers your iOS 14 compliant bases by integrating our custom App Tracking Transparency handler into your Unity iOS project for your ATT-dependent SDK's without having to write any Objective-C code. ByteSyze also comes with our free analytic and remote config tools for all developers to use in their games. Let's get started!

Getting Started:

Go to our ByteSyze SDK Github to download the latest version of the SDK, and set up a ByteBrew developer account here. Also. connect with us and other ByteBrew developers on our Discord.

Import the SDK

Import the ByteSyzeSDK Unity package in the Unity Engine. Go to Window -> ByteBrew -> and Select ByteBrew settings.

Create your game in the ByteBrew Dashboard and copy the Game ID and Game Key from your game settings into the Unity ByteBrew Settings Inspector Panel. Enable the selected platforms that you want to set up and input the correct IDs and Keys.

Initialize the SDK

Go to Window -> ByteBrew -> and Create ByteBrew GameObject. This will create a ByteBrew GameObject prefab inside your current scene. Make sure to put this object in the first or loading scene of your project.

Wherever you initialize your SDK’s or scripts that handle your ATT-dependent SDK’s, this code snippet below uses ByteBrew libraries to call the App Tracking Transparency Framework and returns a response in the action callback code block that holds the users' selection status as well as initialize the ByteSyze SDK.


// Call ByteBrew ATT Wrapper
ByteBrew.requestForAppTrackingTransparency((status) =>
{
    //Case 0: ATTrackingManagerAuthorizationStatusAuthorized
    //Case 1: ATTrackingManagerAuthorizationStatusDenied
    //Case 2: ATTrackingManagerAuthorizationStatusRestricted
    //Case 3: ATTrackingManagerAuthorizationStatusNotDetermined
    Debug.Log("ByteBrew Got a status of: " + status);
    ByteBrew.InitializeByteBrew();

    //Initialize any other SDKs
});

                  

If you are going to only use ByteBrew's App Tracking Transparency completion handler, use the following code piece instead of the above snippet.


// Call ByteBrew ATT Wrapper
ByteBrew.requestForAppTrackingTransparency((status) =>
{
    //Case 0: ATTrackingManagerAuthorizationStatusAuthorized
    //Case 1: ATTrackingManagerAuthorizationStatusDenied
    //Case 2: ATTrackingManagerAuthorizationStatusRestricted
    //Case 3: ATTrackingManagerAuthorizationStatusNotDetermined

    //Initialize any other SDKs
});

                  

That's all there is to it on the Unity code side!

After exporting an Xcode project with our ATT wrapper, make sure that you do the following in your info.plist:

  1. Use the Xcode Property List Editor to add: Privacy - Tracking Usage Description
  2. In the value string field, enter a sentence or statement for the reason behind your tracking request.

The goal of this tutorial was to help iOS Unity developers in using ByteBrew to assist in the post-iOS 14 eras.

Disclaimer: This article was written by Cameron Hozouri, the co-founder of ByteBrew. If you want to continue adding more features from ByteBrew included in the ByteSyze SDK such as receipt validation, go to our documentation page and continue creating.