This Unity plugin allows your app/game to easily show the iOS 14 native App Tracking Transparency popup
View the Project on GitHub Balaso-Software/app-tracking-transparency-for-unity
This plugin allows your app/game to easily show the iOS 14 native App Tracking Transparency popup to your users, meeting Appleās requirement since iOS 14.
Get it on Unity Asset Store
Find the Settings window in your Unity Editor under Window/Balaso/App Tracking for Transparency/Settings
You can obtain, at any time, the current app-tracking authorization status by accessing AppTrackingTransparency.TrackingAuthorizationStatus
property
AppTrackingTransparency.AuthorizationStatus currentStatus = AppTrackingTransparency.TrackingAuthorizationStatus;
Debug.Log(string.Format("Current authorization status: {0}", currentStatus.ToString()));
Register your callback to get notified with the authorization result and request tracking authorization
AppTrackingTransparency.OnAuthorizationRequestDone += OnAuthorizationRequestDone;
AppTrackingTransparency.RequestTrackingAuthorization();
Call RegisterAppForAdNetworkAttribution
or UpdateConversionValue
at anytime to support SkAdNetwork attribution system
AppTrackingTransparency.RegisterAppForAdNetworkAttribution();
AppTrackingTransparency.UpdateConversionValue(3);
using Balaso;
using UnityEngine;
/// <summary>
/// Example MonoBehaviour class requesting iOS Tracking Authorization
/// </summary>
public class AppTrackingTransparencyExample : MonoBehaviour
{
private void Awake()
{
#if UNITY_IOS
AppTrackingTransparency.RegisterAppForAdNetworkAttribution();
AppTrackingTransparency.UpdateConversionValue(3);
#endif
}
void Start()
{
#if UNITY_IOS
AppTrackingTransparency.OnAuthorizationRequestDone += OnAuthorizationRequestDone;
AppTrackingTransparency.AuthorizationStatus currentStatus = AppTrackingTransparency.TrackingAuthorizationStatus;
Debug.Log(string.Format("Current authorization status: {0}", currentStatus.ToString()));
if (currentStatus != AppTrackingTransparency.AuthorizationStatus.AUTHORIZED)
{
Debug.Log("Requesting authorization...");
AppTrackingTransparency.RequestTrackingAuthorization();
}
#endif
}
#if UNITY_IOS
/// <summary>
/// Callback invoked with the user's decision
/// </summary>
/// <param name="status"></param>
private void OnAuthorizationRequestDone(AppTrackingTransparency.AuthorizationStatus status)
{
switch(status)
{
case AppTrackingTransparency.AuthorizationStatus.NOT_DETERMINED:
Debug.Log("AuthorizationStatus: NOT_DETERMINED");
break;
case AppTrackingTransparency.AuthorizationStatus.RESTRICTED:
Debug.Log("AuthorizationStatus: RESTRICTED");
break;
case AppTrackingTransparency.AuthorizationStatus.DENIED:
Debug.Log("AuthorizationStatus: DENIED");
break;
case AppTrackingTransparency.AuthorizationStatus.AUTHORIZED:
Debug.Log("AuthorizationStatus: AUTHORIZED");
break;
}
// Obtain IDFA
Debug.Log($"IDFA: {AppTrackingTransparency.IdentifierForAdvertising()}");
}
#endif
}