Skip to content

Unity Plugin - Installation

Requirements: Unity 2022.3 LTS+ · EDM4U 1.2.179+ · Android API 24+ · iOS 13+ · CocoaPods (iOS builds)


1. Install EDM4U

Download the latest external-dependency-manager-*.unitypackage from the EDM4U releases page, then import it in Unity via Assets › Import Package › Custom Package.

The External Dependency Manager for Unity (EDM4U) resolves the Android Maven and iOS CocoaPods dependencies declared by the plugin.

2. Add the plugin package

Add the plugin to the dependencies in your project's Packages/manifest.json:

Packages/manifest.json
{
  "dependencies": {
    "com.aurion11.a11-mediation-unity-plugin": "https://a11-gh-dist:<YOUR_PAT>@github.com/Aurion11/dist-mediation11-unity-plugin.git#v3.2.10"
  }
}

Replace <YOUR_PAT> with the Personal Access Token (PAT) provided by Aurion11. The repositories are private; no GitHub account invitation is needed.

The URL ends with the version tag of the plugin release to integrate. The example uses the latest release. See the Changelog.

Caution

Always end the URL with an explicit version tag. Without it, the package tracks the repository's default branch and updates without your control.

To upgrade later, change only the version tag at the end of the URL, then switch back to Unity so the Editor re-resolves the package. Check the Changelog for what changed.

3. Declare ad network adapters

Declare an adapter for each mediation platform or ad network active on your MDN11 account. Aurion11 confirms which ones those are during integration.

Create Assets/Editor/A11MediationAdapterDependencies.xml with the contents for your mediation setup. If you use several networks, put all their iosPod and androidPackage entries in one file, and list each pod or package only once:

Assets/Editor/A11MediationAdapterDependencies.xml
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
  <iosPods>
    <sources>
      <source>https://cdn.cocoapods.org/</source>
      <source>https://github.com/Aurion11/dist-cocoapods-specs</source>
    </sources>

    <iosPod name="A11MediationAppLovinMAXAdapter" version="= 13.0.13" minTargetSdk="13.0"/>
  </iosPods>

  <androidPackages>
    <androidPackage spec="com.a11.sirius.adapters:applovin:13.0.10"/>
  </androidPackages>
</dependencies>

On iOS, AdMob and Google Ad Manager use the same pod. If you use both, declare it once and add both Android packages.

Assets/Editor/A11MediationAdapterDependencies.xml
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
  <iosPods>
    <sources>
      <source>https://cdn.cocoapods.org/</source>
      <source>https://github.com/Aurion11/dist-cocoapods-specs</source>
    </sources>

    <iosPod name="A11MediationGoogleAdapter" version="= 13.0.7" minTargetSdk="13.0"/>
  </iosPods>

  <androidPackages>
    <androidPackage spec="com.a11.sirius.adapters:google-mediation:24.0.11"/>
  </androidPackages>
</dependencies>

On iOS, AdMob and Google Ad Manager use the same pod. If you use both, declare it once and add both Android packages.

Assets/Editor/A11MediationAdapterDependencies.xml
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
  <iosPods>
    <sources>
      <source>https://cdn.cocoapods.org/</source>
      <source>https://github.com/Aurion11/dist-cocoapods-specs</source>
    </sources>

    <iosPod name="A11MediationGoogleAdapter" version="= 13.0.7" minTargetSdk="13.0"/>
  </iosPods>

  <androidPackages>
    <androidPackage spec="com.a11.sirius.adapters:google:24.0.9"/>
  </androidPackages>
</dependencies>

LevelPlay is supported on Android only.

Assets/Editor/A11MediationAdapterDependencies.xml
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
  <androidPackages>
    <androidPackage spec="com.a11.sirius.adapters:levelplay:9.0.0"/>
  </androidPackages>
</dependencies>

4. Android: Configure Gradle

4.1 Store your Gradle credentials

Add the credentials to your user-level Gradle properties, not to a project file that is committed to version control:

~/.gradle/gradle.properties
a11PackagesUser=a11-gh-dist
a11PackagesPass=<PAT provided by Aurion11>

4.2 Enable custom Gradle templates

In Unity, open Project Settings › Player › Android › Publishing Settings and enable these three options:

  • Custom Main Gradle Template
  • Custom Gradle Properties Template
  • Custom Gradle Settings Template

4.3 Add the A11 repository

In Assets/Plugins/Android/settingsTemplate.gradle, read the credentials right after the pluginManagement { } block, and add the A11 Maven repository next to the repositories already in dependencyResolutionManagement:

Assets/Plugins/Android/settingsTemplate.gradle
// Resolve A11 credentials at settings scope
def a11User = providers.gradleProperty("a11PackagesUser").getOrElse(System.getenv("A11_PACKAGES_USER") ?: "")
def a11Pass = providers.gradleProperty("a11PackagesPass").getOrElse(System.getenv("A11_PACKAGES_PASS") ?: "")

dependencyResolutionManagement {
    repositories {
        // ...existing repositories

        // A11 SDK and adapters
        maven {
            url "https://maven.pkg.github.com/Aurion11/dist-mediation11-android"
            credentials {
                username = a11User
                password = a11Pass
            }
        }
    }
}

4.4 Run Force Resolve

In Unity, select Assets › External Dependency Manager › Android Resolver › Force Resolve.

EDM4U resolves the Android dependencies of the plugin and your adapters, and adds the required AndroidX entries to gradleTemplate.properties. Run it again whenever you add or change adapters. If the resolve fails, check the credentials from step 4.1.

5. iOS: Set up GitHub credentials

CocoaPods needs the PAT provided by Aurion11. Replace <YOUR_PAT> in the commands below and run them:

# Store the specs repo credentials in macOS Keychain, used by pod install
git ls-remote https://a11-gh-dist:<YOUR_PAT>@github.com/Aurion11/dist-cocoapods-specs.git HEAD

# Set the token used to download the binary frameworks (use ~/.bash_profile for bash)
echo 'export A11_GITHUB_TOKEN=<YOUR_PAT>' >> ~/.zshrc
source ~/.zshrc

# Unity doesn't read ~/.zshrc, so also make the token visible to apps like Unity
launchctl setenv A11_GITHUB_TOKEN <YOUR_PAT>

Then quit and reopen Unity Hub and Unity, so they pick up the token. launchctl setenv doesn't persist when you restart your Mac, so run it again after a restart.

6. Set privacy signals

Set any privacy signals that may apply to your app before you initialize the SDK, so ad networks get the user's privacy status from the first ad request. If you use a consent management platform (CMP), we recommend waiting until it has established the user's consent status. See Privacy signals.

7. Initialize the SDK

Initialize the SDK as early as possible in your app's lifecycle, so it can fetch its configuration and start pre-caching ads, so they're ready by your first ad request. You need an app key and host URL from Aurion11.

Recommended

Don't initialize a mediated network's SDK outside MDN11. Most SDKs can only be initialized once and use the config of whichever caller is first, so MDN11 may not be able to apply its own config.

Caution

Set privacy signals before initializing MDN11 SDK. See Privacy signals.

using UnityEngine;
using Aurion11.A11Mediation;

public class AdsInitializer : MonoBehaviour
{
    [SerializeField] private string androidAppKey = "YOUR_ANDROID_APP_KEY";
    [SerializeField] private string iosAppKey     = "YOUR_IOS_APP_KEY";
    [SerializeField] private string hostUrl       = "YOUR_HOST_URL";

    void Awake()
    {
#if UNITY_ANDROID
        string appKey = androidAppKey;
#elif UNITY_IOS
        string appKey = iosAppKey;
#else
        string appKey = androidAppKey;
#endif

        A11MediationSDK.Initialize(appKey, new[] { hostUrl });
    }
}

Next steps

Integrate your ad units.