Skip to content Skip to sidebar Skip to footer

Getting The Google Advertising ID And Limit Advertising

I'm building a Unity Android app, and looking at some advertising. One of the services we are considering requires my google advertising ID and limit advertising state in order to

Solution 1:

I was able to get the desired data using the following code:

string advertisingID = "";
bool limitAdvertising = false;

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();   
limitTracking = (adInfo.Call<bool> ("isLimitAdTrackingEnabled"));

Post a Comment for "Getting The Google Advertising ID And Limit Advertising"