Integrating IronSource Mediation with Huawei Ads using the HMS Unity Plugin: Step by Step Guide

Hilal Tepecik
Huawei Developers
Published in
5 min readApr 3, 2023

--

By stokpic picture uploaded to Pixabay

Introduction:🛸

As the mobile gaming industry continues to expand, developers are looking for efficient ways to monetize their applications. One popular solution is incorporating ads through mediation platforms, such as IronSource. This article will guide you through the process of integrating IronSource mediation with Huawei Ads using the Huawei Mobile Services (HMS) Unity plugin. By following these steps, you will be able to maximize revenue by serving ads from multiple networks in your Unity game.💰

🔩What is IronSource?

Ironsource logo

IronSource mediation is a platform that helps mobile app developers optimize revenue by managing and integrating multiple ad networks and demand sources into their apps through a single interface. With IronSource mediation, developers can view performance metrics, set up ad prioritization rules, and optimize ad delivery for a better user experience.

The platform supports various ad formats, including banner, interstitial, rewarded video, and native ads. By using IronSource mediation, developers can increase their ad revenue while ensuring that ads are relevant, non-intrusive, and well-timed.

🌡️What is HMS Unity Plugin?

The HMS Unity Plugin is a plugin for the Unity game engine that allows developers to integrate the Huawei Mobile Services (HMS) Core SDK into their Unity projects. The plugin provides a set of tools and APIs that enable developers to access the features and services provided by HMS, such as the Ads Kit, Push Kit, and Analytics Kit. By integrating the HMS Unity Plugin into their Unity projects, developers can leverage the capabilities of HMS and create engaging and feature-rich mobile applications for Huawei devices.

🛠 ️Prerequisites:

  1. A AppGallery Connect account.🔑
  2. An IronSource account.💻
  3. Ironsource Mediation and Huawei Ads Configuration.

For the 3rd step you can follow this detailed guide‘s ’ “Creating an Account on IronSource and Connecting with Unity 🖇”. “Adding Huawei Ads to IronSource” sections. We’ll take over the rest.

Step 1:🌌Install the IronSource Unity Plugin 🌌

The IronSource Unity Plugin enables IronSource mediation functionality in Unity. Follow these steps to install the plugin:

  1. 📥Download the IronSource Unity Plugin.
  2. 📤Import the plugin into your Unity project by selecting Assets > Import Package > Custom Package and selecting the downloaded plugin.
  3. 🚶‍♂️Follow the installation wizard to complete the installation.
IronSource SDK

After you Import every dependency there will be a pop-up asking enabling Android resolver. You need to import it first by clicking “Import”

Mobile Dependency Resolver

After the completion of Android Resolve, there will be Win32Exception.

Win32Exception

To fix this you need to visit this this github repo and download gradlew.bat.

And you need to place it into your projects Temp>PlayServicesResolverGradle folder.

gradlew.bat

Now return back to project and reimport the dependencies by right clicking on a spare place of project console.

Reimport Dependencies

After the reimport complete Android Resolver should work just fine and complete the resolve.

Resolution Succeed

Step 2: 🛡 ️Configure Publishing Settings 🛡

  1. Navigate to Edit -> Project Settings -> Player -> Publishing Settings in Unity.
  2. Select “Custom Main Gradle Template”, “Custom Base Gradle Template”, and “Custom Gradle Properties Template”. This will let you override the mainTemplate.gradle, baseProjectTemplate.gradle, and gradleTemplate.properties files in the project.
“Custom Main Gradle Template”, “Custom Base Gradle Template”, and “Custom Gradle Properties Template”.

3.

📝Open baseProjectTemplate.gradle in a text editor and add the maven lines from the mediation readme file:

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

📝Open mainTemplate.gradle in a text editor and add the following implementation lines depending on your selected platform:

📝Lastly, open gradleTemplate.properties and make sure to add the following lines:

Step 3:🔧 Make Sure the Implementation of HMS Unity Plugin🔧

  1. Download the latest version of the HMS Unity Plugin from the official HMS Unity Plugin Gitbook. If you haven’t already.

Step 4: 🔌 Initialize Huawei Ads in your Unity project🔌

  1. In your Unity project, go to Editor > Huawei > Kit Settings
  2. Enable the Ads Kit:
Hms Kits

Step 5: 🧰 Implement ad units 🧰

  1. In your Unity project, create scripts for each ad unit you want to implement (Huawei ads only supports rewarded video, interstitial).
  2. Use IronSource’s API methods to load and display ads in your game.
  3. For example, to load and show interstatial and rewarded ad, add the following code to your script:

Step 6: 🕵️‍♀️Test your integration🕵️‍♀️

  1. Build and run your Unity project on a device.
  2. Test the ad units you have implemented to ensure they are functioning correctly.

And congrats! You made it till the end!

🏁Conclusion:

Integrating IronSource mediation with Huawei Ads using the HMS Unity plugin allows you to effectively monetize your mobile games by serving ads from multiple networks. By following this comprehensive guide, you can set up and implement this solution in your Unity project, allowing you to maximize revenue and enhance the user experience of your game.

We hope this guide has been helpful and wish you all the best in your game development journey.

Goodbye and see you soon!

🛰️References

--

--

Hilal Tepecik
Huawei Developers

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