-
-
Save PSHalanYeats/1d8ba73ba03b6794fdb51960f87d6f8f to your computer and use it in GitHub Desktop.
PostBuild IDFA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEditor.Callbacks; | |
#if UNITY_IOS | |
using UnityEditor.iOS.Xcode; | |
#endif | |
using System.IO; | |
public class PostBuildStep | |
{ | |
/// <summary> | |
/// Description for IDFA request notification | |
/// [sets NSUserTrackingUsageDescription] | |
/// </summary> | |
const string TrackingDescription = | |
"This identifier will be used to deliver personalized ads to you. "; | |
[PostProcessBuild(0)] | |
public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToXcode) | |
{ | |
if (buildTarget == BuildTarget.iOS) | |
{ | |
AddPListValues(pathToXcode); | |
} | |
} | |
static void AddPListValues(string pathToXcode) | |
{ | |
// Get Plist from Xcode project | |
string plistPath = pathToXcode + "/Info.plist"; | |
// Read in Plist | |
PlistDocument plistObj = new PlistDocument(); | |
plistObj.ReadFromString(File.ReadAllText(plistPath)); | |
// set values from the root obj | |
PlistElementDict plistRoot = plistObj.root; | |
// Set value in plist | |
plistRoot.SetString("NSUserTrackingUsageDescription", TrackingDescription); | |
// save | |
File.WriteAllText(plistPath, plistObj.WriteToString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment