The Admob plugin for Unity - Android does not supply an EEA permission request form like the standard Android plugin does. So, I have created my own and it works great.

My only problem is how do I check if I am in the EEA and need to request permission? Again, this feature is supplied for a standard Android app.

I know I can make a simple Android plug-in and call it but that seems a bit over the top.


1 Answer 1


Using AdMob’s Consent SDK, which you can import using the Jar Resolver (see below) or as a line in the mainTemplate.gradle override, you can interact with Java classes using a set of classes:

  • AndroidJavaObject which is a class that can instantiate and act as a Java object
  • AndroidJavaClass which is similar but works for calling static methods on Java classes
  • AndroidJavaProxy which can act as a Java interface in C#. Implement the Java interface’s methods by duplicating the correct name and method signatures (using AndroidJavaObject for any Java object arguments)
  • AndroidJavaRunnable lets you pass in a C# method or anonymous delegate as a java.lang.Runnable.

For example, converting the first block of code in the Consent SDK integration guide from Java to C#:

        ConsentInformation consentInformation = ConsentInformation.getInstance(context);
        String[] publisherIds = {"pub-0123456789012345"};
        consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
            public void onConsentInfoUpdated(ConsentStatus consentStatus) {
                 // User's consent status successfully updated.

            public void onFailedToUpdateConsentInfo(String errorDescription) {
                 // User's consent status failed to update.


        AndroidJavaClass playerClass = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
        AndroidJavaObject context = playerClass.GetStatic<AndroidJavaObject> ("currentActivity");
        AndroidJavaObject consentInformation = new AndroidJavaClass("com.google.ads.consent.ConsentInformation").CallStatic<AndroidJavaObject>("getInstance",context);
        string[] publisherIds = new[] {"pub-0123456789012345"};
        consentInformation.Call("requestConsentInfoUpdate", publisherIds, new ConsentInfoUpdateListener());


class ConsentInfoUpdateListener : AndroidJavaProxy {
    public ConsentInfoUpdateListener() : base("com.google.ads.consent.ConsentInfoUpdateListener") {}

    public void onConsentInfoUpdated(AndroidJavaObject consentStatusObj) {
        // User's consent status successfully updated.
        // Note that Java Enums are syntax sugar for objects, so we need to get the index to figure out which one it is:
        int consentStatus = consentStatusObj.Call<int>("ordinal");
        //for clarity, you could declare your own copy of the enum in C#, but you can also just compare to the int value of the original (0,1,2 for PERSONALIZED, NON_PERSONALIZED, UNKNOWN)

    public void onFailedToUpdateConsentInfo(string errorDescription) {
         // User's consent status failed to update.

If you want to use the jar resolver to integrate the consent SDK, assuming you are using any recent version of said resolver that uses xml files for dependency definitions, you can add this xml file to your project (probably in an Editor folder, but anywhere should technically work):

    <androidPackage spec="com.google.android.ads.consent:consent-library:1.0.6" />
  <!-- you can also include the iOS version here, although interacting with that version is outside the scope of this answer, and if you are targeting Android only, this section is not necessary: -->
    <iosPod name="PersonalizedAdConsent"/>
  • \$\begingroup\$ I am having difficulty importing the the consent addon. I tried adding the "compile" to gradle and now it doesn't compile. I included url "maven.google.com" as detailed. What other way is there because the resolver doesn't bring it in. \$\endgroup\$
    – theblitz
    Jul 29, 2018 at 23:51
  • \$\begingroup\$ @theblitz I’ve added an example for using the jar resolver \$\endgroup\$
    – Ed Marty
    Jul 30, 2018 at 12:01
  • \$\begingroup\$ Still didn't help. In the end I downloaded the jar file and it works greats (after I also downloaded Gson) \$\endgroup\$
    – theblitz
    Jul 30, 2018 at 22:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .