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?
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?
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;
}