Solution 1 :
Manually call into Java:
public static string GetAndroidAdvertiserId()
{
string advertisingID = "";
try
{
AndroidJavaClass up = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = up.GetStatic<AndroidJavaObject> ("currentActivity");
AndroidJavaClass client = new AndroidJavaClass ("com.google.android.gms.ads.identifier.AdvertisingIdClient");
AndroidJavaObject adInfo = client.CallStatic<AndroidJavaObject> ("getAdvertisingIdInfo", currentActivity);
advertisingID = adInfo.Call<string> ("getId").ToString();
}
catch (Exception)
{
}
return advertisingID;
}
Problem :
It seems that the way to access the advertising ID that worked in Unity3d 2019.4, RequestAdvertisingIdentifierAsync is deprecated for android in the 2020.1 release.
How can I access the advertising id in that version?
Comments
Comment posted by Konstantine Rybnikov
May I ask how do you know it’s deprecated?
Comment posted by Sam Tyurenkov
Did you manage it? Please post a solution.
Comment posted by unity3d.com/unity/beta/2020.1.0b14
Patch notes also confirm
Comment posted by stackoverflow.com/questions/34582610/…
If all else fails you may be able to request it directly from the Google API. If so, the information in the question and answer on this page might be of use potentially: