How to use Huawei Ads with Smaato Mediation

Berke Coban
Huawei Developers
Published in
5 min readJun 2, 2021

In this article, we will talk about showing Huawei ads with Smaato through mediation.

Supported ad types are Banner and interstitial ads.

What is ad meditation?

Ad Mediation gives multiple ad networks access to your ad inventory, and gets them to compete against each other for ad slots. This process increases competition among advertisers and in return, increases your ad revenue. The mediation platform checks what CPM all the various ad networks are offering and looks for the highest one.

Getting Started

Creating an Ad unit id

First things first, We need to create our ad units using Huawei Ads Publisher Service. Check this link to start.

This medium post also might help you for creating a Huawei Ad slot id. For Smaato mediation we only need a banner or interstitial slot.

Note: While creating a banner ad unit slot make sure your ad size is a small banner (320x50) because only this dimension is supported by Smaato.

Smaato Publisher Platform (SPX)

We created our Huawei ad slots. Our next step will be creating ad units from the Smaato publisher console and enabling mediation for our Huawei ad slots. Follow the steps below :

➯ Click this link to start using the Smaato SPX portal. Create an account if you don't have one. After the process is completed, you will be directed to the Smaato dashboard.

➯ After you entered the dashboard successfully, Our next move will be creating an app. Switch to the inventory tab and click “New App”.

Fill this part with the related information about your android application. You don't need to define ad spaces from this section. We will create them in the next step.

➯ After the app creation is completed, switch to the inventory tab and click the app you created under “Apps”.

➯ Click “New Adspace” afterward.

Give your ad space, name, and description. Ad Format will be “Display Only (Image/Rich Media).” For dimension If you want to create a banner ad, select Banner Phone (320x50), if you want to create an Interstitial ad, select “Fullscreen Interstitial Portrait (320x480)” and click save.

➯ Our Smaato ad unit is ready. Let’s set up our mediation. Switch to the Network tab from the dashboard and click “New Network”.

➯ Select “Custom SDK Network” and add a line item for your custom network.

➯ Every line item you created represents one ad unit. When you try to create a line item for your network this page will show up.

This setting page is the most important part of our mediation. Enter the start date, end date, and CPM rate for your needs.

Class name Banner ad

 com.hmscl.huawei.smaato_mediation.CustomMediationBanner

Class name Interstitial ad

com.hmscl.huawei.smaato_mediation.CustomMediationIntersitial

Method name Banner ad

loadCustomBanner

Method name Interstitial ad

loadCustomIntersitial

Custom Data:

{“AD_UNIT_ID”:”YourHuaweiAdUnitId"}

Note: Don't forget to link this line item with your Smaato ad unit, Under the “Targeting” section you have an option to select it.

We are done with the Smaato dashboard. Now we need to make some preparations in Android Studio.

Android Studio Preparations

Initialize Smaato Legacy SDK

Enter Spx dashboard, upper right corner of the page select “Integration options”. Switch to the Android tab and download the Legacy SDK.

Follow this guide to add the Legacy SDK to your project.

Initialize Huawei Mediation Plug-in

In the project-level build.gradle, include Huawei’s Maven repository.

repositories {
google()
jcenter() // Also, make sure jcenter() is included
maven { url 'https://developer.huawei.com/repo/' }
}

...

allprojects {
repositories {
google()
jcenter() // Also, make sure jcenter() is included
maven { url 'https://developer.huawei.com/repo/' }
}
}

First, download the “smaato_mediation-release.aar” file from this link.

Then in Android Studio, after click File->New->New Module, select Import AAR&JAR. Then select the downloaded aar file.

Finally In the app-level build.gradle,

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(":smaato_mediation-release")
}

For more details or any updates, follow this link to check the github page.

Example Banner Java Code

This is our view for the banner ad. add this piece of code to your layout. replace the ad space and publisher id.

Let’s continue with Java code.

This is the simple banner code. If you want a detailed implementation, I recommend you to check this official guide.

Note: If you set your ad space and publisher id to zero, the test ad will be shown for the banner ad.

Note: If you don't know your publisher id, go to the Spx dashboard and check the inventory tab.

References

--

--