Streamlining Ad Integration with Open Mediation and HMS Unity Plugin for Unity Developers

Hilal Tepecik
Huawei Developers
Published in
6 min readMar 31, 2023

--

Image by PIRO from Pixabay

Introduction🎸

For app developers, integrating ads into apps is a great way to generate revenue. A popular platform, Open Mediation mediation is the preferred option for many developers who want to display ads. However, if you want to maximize your app’s revenue potential and reach a wider audience, you can integrate Huawei Ads into Open Mediation compatibility using the HMS Unity Plugin in Unity. This article will guide you through this process!

What is Open Mediation?

Open Mediation is a mobile ad brokerage platform that allows app developers to easily manage multiple ad networks and demand sources in one unified SDK integration. With Open Mediation, developers can access a wide range of global demand sources, including popular networks like AdMob, Facebook Audience Network, and Unity Ads, reducing the complexity and hassle of ad integration and maximizing their revenue potential. In addition, Open Mediation provides real-time ad performance analysis and optimization tools to help developers optimize their monetization strategies and improve the user experience of their apps.

What is HMS Unity Plugin? 🤖

HMS Unity Plugin is an open source plugin that facilitates integration between Huawei Mobile Services and Unity. This plugin provides many services to developers such as Account Management, In-App purchase including Huawei Ads and can be made Open Mediation compatible with the HMS Unity Plugin. Huawei Ads help apps reach a wider audience and earn more.

The benefits of using the HMS Unity Plugin include the following:

🤝💻💼 — Easy integration with HMS services
🚀📈💪 — Improved app performance and stability
💰💸💵 — Increased income potential
🆕🔥📱 — Access to new features and services

Prerequisites: 📋

Before proceeding with the HMS Unity Plugin and Open Mediation integration, ensure that you have successfully completed the following prerequisite:

  • Unity Project: You need an open Unity project to integrate HMS Unity Plugin and Open Mediation. You can create a new project by downloading and installing the Unity Editor.
  • Prepare Mediation Network: Make sure you have set up mediation groups and Ad units in your Open Mediation account and correctly configured Huawei Ads as a mediation network. This will allow you to view ads from both platforms without any hassle.🔄🔗

Now let’s move on to the part of integrating Huawei Ads with Open Mediation mediation in Unity using the HMS Unity Plugin. To that end, we will provide you with 5 easy steps.

  1. 🔧 Install Open Mediation Unity SDK to enable Open Mediation functionality.
  2. ⚙️ Configure Unity project settings for custom Gradle files.
  3. 🌐 Import and set up the HMS Unity Plugin for your project.
  4. 📝 Replace the gradle files with the required code snippets and save.
  5. ✅ Enable Ad Kit in HMS Unity Plugin.

Let’s go!

1️⃣ Step 1: Install Open Mediation Unity SDK 🔧

The first step in this integration process is to install the Open Mediation Unity SDK into your Unity project. This SDK provides the tools needed to display Open Mediation ads in your app. Just follow the Open Mediation official Unity plugin documentation to get started.

Open Mediation Unity SDK Yükleme

📌Note: Don’t forget to download the Open Mediation Unity Integration version with the Unity Version you are using. I downloaded OpenMediationUnity(2021.2.1.5).

Click Add Selected Registries on the package manager resolver that opens first.

Package Manage Resolver

Then you will see the migration pop-up about the package migration. Click Apply.

Paket Taşıma

If you are not developing on XCode, delete the Google.IOSResolver.dll file to avoid XCode related errors.

Google.IOSResolver.dll

2️⃣ Step 2: Configure Your Project Settings ⚙️

Next, go to your Unity Editor and follow these steps:

“Edit” -> “Project Settings” -> “Player” -> “Publishing Settings”
“Custom Main Gradle”, “Custom Base Gradle”, and “Custom Gradle Properties.” tick the boxes next to them.

“Custom Main Gradle”, “Custom Base Gradle”, and “Custom Gradle Properties.”

These settings ensure that your project is prepared for integration.

3️⃣ Step 3: Install HMS Unity Plugin and Set Up Project 🌐

Download the HMS Unity Plugin and import it into your project. After importing the plugin, make sure to adjust your project settings as needed to enable HMS integration. Detailed instructions can be found officially in the HMS Unity Plugin.

HMS Unity Package İndirme

4️⃣ Step 4: Modify and Save Gradle Files 📝

To ensure seamless compatibility between Open Mediation and HMS Unity Plugin, you need to add some custom code snippets to your Gradle files. Assets -> Plugins -> Android.

📌Note: Before Unity 2019.2, there is only one Gradle template, which is Custom Gradle Template.

Open the baseProjectTemplate.gradle file in a text editor and add these lines for synchronization:

📌Note: If Unity version is lower than 2019.2 these maven lines also need to be added to project.repositories section in mainTemplate.gradle. The minimum supported Gradle Tools version is 3.4.3.

🎥In the last case baseProjectTemplate.gradle should look like this;

baseProjectTemplate.gradle

Open mainTemplate.gradle in a text editor and add the following application lines depending on your chosen platform:

🎥In the last case mainTemplate.gradle should look like this;

mainTemplate.gradle

Finally open the gradleTemplate.properties file and make sure to add the following lines:

🎥In the last case gradleTemplate.properties should look like this;

gradleTemplate.properties

5️⃣ Step 5: Enable Ad Kit in HMS Unity Plugin ⚙️

Now go back to Unity Editor and follow these steps:

👉Click “Huawei”.
👉Go to “Kit Settings.”
👉Enable the “Ads Kit” option.

HMS Unity Plugin Kitleri

This will ensure that the HMS Unity Plugin is ready to display Huawei ads in your app. 🎉 That was all! 🎉

🖼️ Display Huawei Ads 🖼️

Once the integration is complete, you can now view the ads. Note that the Ad types supported through Open Mediation for Huawei ads are Banner, Interstitial and Rewarded ads. You can find the relevant code examples by clicking the link in the previous sentence. You can use this guide to initialize ads;

Here is the real banner ad from Huawei Ads with the build we created using OpenMediation🔮

OpenMediation Reklam Gösterimi

Conclusion🎉

When you combine Open Mediation compatibility with Huawei Ads, you can reach a wider audience and generate higher revenue from your app.

The HMS Unity Plugin further simplifies this process by making it easy to display ads. Don’t forget to download the Open Mediation Unity Integration version appropriate for the Unity version you have installed. Thus, using the HMS Unity Plugin, integrating Huawei Ads with Open Mediation compatibility in Unity will be a simple and direct process. This article will guide you step-by-step to help you achieve this integration.

If you have any questions or comments, please specify below.

See you in another article!

References🛸

--

--

Hilal Tepecik
Huawei Developers

Game and SDK Developer @Huawei - Unity, Unreal, HMS Unity Plugin, XR Interactions Toolkit