Getting started
Add XMediator to your Unity Project
Download the latest release of XMediator:
Requirements:
- Unity 2020.3.34f1 or later.
- Minimum Android version supported: Android Lollipop 5.0, API 21.
- Minimum iOS version supported: iOS 12, Xcode 15.
Enable Gradle Templates
For a cleaner dependency management experience, enable Gradle Templates for Android builds inside the Unity Editor if you haven't already. This will avoid bloating your Assets folder with the native libs each ad adapter requires.
To do this go to File > Build Settings... > Player Settings... > Android > Publishing Settings > Build
and make sure Custom Main Gradle Template
is checked.
Import the package into a project
To add XMediator to your Unity project:
- Make sure your project is open
- Double click the downloaded
.unitypackage
file or go toAssets > Import Package > Custom package...
to import it manually
Unity will load the package and then show a confirmation dialog displaying the files to be added after the import. Click Import
to finish importing the assets.
Configure settings
Use the settings window to configure your integration tokens, Google Ads AppId, and target build options. To begin, go to XMediator > Settings
.
Here you can configure the following items:
- Publisher: is required to resolve custom publisher dependencies. It is safe to use
default
here. - Android Maven Repository Token: required to resolve Android Maven dependencies. (*)
- Dependency Manager Token: required to use the built-in dependency manager. (*)
- Disable GoogleAds Android AppId: check to avoid automatically appending the GoogleAds AppId meta element to the Android manifest. Useful when your app already has this id configured.
- GoogleAds Android AppId: set the app id to include in the final AndroidManifest. Required when
Disable GoogleAds Android AppId
is unchecked. - GoogleAds iOS AppId: set the app id to include in the Info.plist file.
- Skip Swift Configuration: check to avoid setting up Swift on the iOS Xcode project. XMediator requires Swift to be configured, but you can disable this configuration if you have a different tool doing it elsewhere.
- Skip SkAdNetwork Ids Configuration: X3M automatically adds the relevant SKAdNetwork Ids to the application’s Info.plist. Select this option to disable this behaviour.
- Enable GMA properties tag fix: See Optional: Enable GMA workaround for projects with Unity 2021 and lower
(*) The integration tokens are required to access our repositories during the closed beta. Please contact your integration support specialist to request or renew your project's access tokens.
Install adapters
To integrate additional mediation network adapters go to XMediator > X3M Dependency Manager
, where you will see a list of the adapters available for installation, as well as the current version of XMediator.
Dependency Manager
Click Install on any adapter you wish to add to your project and XMediator will take care of downloading and importing the assets. Depending on the needs of your project, you can install, upgrade, downgrade, and delete adapters.
It also performs a validation of adapter version compatibility with Core (or other adapters). If you encounter the message below after a version change, you must match the required version. See the changelog documentation for more information.
After the installation completes, remember to run EDM4U's Dependency Resolver by going to Assets > External Dependency Manager > Android Resolver > Force Resolve
to update the Gradle Templates. This will make sure all dependencies get correctly added into your final Android build. For more information check out Google's EDM4U official repository.
Optional: Enable GMA workaround for projects with Unity 2021 and lower
When integrating the Google Ads adapter in projects with Unity 2021 or lower you might get the following error on Android builds:
This error occurs due to a new property introduced on GMA SDK 22.5.0 that is not supported on older AGP versions. To fix this, you can enable the GMA workaround to remove the new property:
- Go to
XMediator > Settings
- Mark
Enable GMA properties tag fix
as checked. - Copy the following code snippet into
mainTemplate.gradle
:
Initialize the SDK
Before requesting any ad, make sure to call XMediatorAds.StartWith()
. This method configures your Application Key, and fetches the required configuration parameters for the ad placements in your app, among other things.
Additionally, you may want to wait for the initialization callback to complete. This will ensure that your placement' requests have the necessary prebid configurations.
XMediatorAds.StartWith(
appKey: "<your-app-key>",
initSettings: new InitSettings(
userProperties: new UserProperties(
userId: "<your-user-id>"
)
),
initCallback: result =>
{
Debug.Log("Initialization complete! You can start loading your placements!")
}
);
You may also configure additional options by passing in an InitSettings
instance to the initialize method.
For a complete list of available options please see InitSettings Class
Warning
To ensure the SDK is correctly configured before ad mediation begins, any method that performs an ad request will raise an exception if they are called before XMediatorAds.StartWith()
is invoked.
It is mandatory to wait for the init callback to complete before making any ad request.