HMS Ads Kit

Ece Aydın
Huawei Developers
Published in
6 min readAug 28, 2020

Nowadays, traditional marketing has left its place on digital marketing. Advertisers prefer to place their ads via mobile media rather than printed publications or large billboards. In this way, they can reach their target audience more easily and they can measure their efficiency by analyzing many parameters such as ad display and the number of clicks.

In addition to in-app purchases, the most common method used by mobile developers to generate revenue from their application is to create advertising spaces for advertisers.

In this sense, Huawei Ads meets the needs of both advertisers and mobile developers. So what is this HMS Ads Kit, let’s take a closer look.

What is Huawei Ads Kit? What are its advantages?

HMS Ads Kit is a mobile service that helps us create high quality and personalized ads in our application. It provides many useful ad formats such as native ads, banner ads and rewarded ads to more than 570 million Huawei device users worldwide.

Advantages of Huawei Ads Kit :

Provides high income for developers

It collaborates with a large number of premium advertisers covering industries such as e-commerce, education, automobile and branding to ensure with high fill rate of ad spaces and competitive effective cost per mile (eCPM).

Creates advertising contents based on user profiles that makes it possible to earn money more efficiently by using the analysis of users’ interests.

It follows the most advantageous revenue sharing and incentive policies in the sector so that you can generate more income. (For 2020, this rate is 90% of revenue on behalf of developers)

Rich ad format options

It offers a wide variety of mainstream ad formats such as native, rewarded, banner and splash advertisements to best suit your application’s design requirements in different scenarios.

It saves you ad development time with its fast integration based on native dynamic templates.

It saves you ad development time with its fast integration based on native dynamic templates. Also, the smart pairing functionality provides a consistent user experience across applications on different devices.

It allows users to download apps with a single click without being redirected to another screen. In this way, it prevents user losses caused by redirection.

Provides versatile support

It facilitates analysis with visualized reports.
It easily handles professional reviews. With the help of the ad review expert group, it maintains ad quality and prevents inappropriate and illegal ad content.

HUAWEI Ad Publisher Service uses Huawei’s extensive user base and extensive data capabilities to deliver high-quality advertising content to the target audience of the ad with OAID.

What is OAID?

OAID, Open Advertising Identifier, offered by Huawei Ads, is a non-persistent device identifier. It allows users to meet personalized advertising content in line with their interests.

You can also collaborate with third-party tracking platforms using OAID to measure advertising efficiency and calculate revenue.

It protects the privacy of users under the GDPR (EU General Data Protection Regulation). Users can reset the OAID in the device settings if they wish. If they wish, they can disable personalized ads using the way Settings> Privacy> Ads and Privacy or Settings> Security & privacy> More settings> Device identifier.

Ads Formats

Many ad formats are offered with the Huawei Ads Kit so that you can choose the format that will provide the best experience for your users. Currently, you can easily integrate banner, native, rewarded, interstitial and splash ads types into your application.

Banner Ads are rectangular ad images located at the top, middle or bottom of an application’s layout. Banner ads are automatically refreshed at intervals. When a user taps a banner ad, in most cases the user is taken to the advertiser’s page.

Rewarded Ads are generally preferred in gaming applications. They are the ads that in full-screen video format that users choose to view in exchange for in-app rewards or benefits.

Native Ads are ads that take place in the application’s interface in accordance with the application flow. At first glance they look like they are part of the application, not like an advertisement.

Interstitial Ads are full screen ads that cover the application’s interface. Such that ads are displayed without disturbing the user’s experience when the user launches, pauses or quits the application.

Splash Ads are ads that are displayed right after the application is launched, before the main screen of the application comes.

How is HMS Ads Kit Integrated into the Project?

First of all, we need to meet several requirements to integrate the HMS Ads Kit into our project. These are;

  • Android Studio
  • Java JDK (1.7 or later)
  • HMS Core (APK) (4.0.0 or later)

Before using HMS kits, we need to make sure we connect our project to AppGallery. You can find detailed information on how to integrate AppGallery Connect SDK into the project in this article.

1.Adding grades dependencies and configuring obfuscation scripts

  • First, let’s add the following dependencies to the build.gradle file at the project level.
  • Then add build dependencies to the application level build.gradle file and click Sync Now to synchronize our project.
implementation 'com.huawei.hms:ads-lite:13.4.30.301'
  • Finally, let’s configure the cloaking scripts in app/proguard-rules.pro file.
-keep class com.huawei.openalliance.ad.** { *; }
-keep class com.huawei.hms.ads.** { *; }

2.Huawei Ads SDK integration

  • Let’s call HwAds.init() in the onCreate() method of the MainActivity.java class to launch the HUAWEI Ads SDK.

I will use the banner ads format in this project. If you wish, you can use other ads formats offered by Huawei.

3.Adding the BannerView Class

  • Let’s add BannerView to the XML layout file that we will access via the path res> layout> activity_main.xml. And in order, let’s set the hwads:adId for the ad slot ID and hwads:bannerSize for the ad size.

You can use the table below to use different banner sizes.

  • After creating the XML file, we need to add BannerView to the MainActivity.java file and set the ad slot ID and banner ad size using setAdId and setBannerAdSize respectively.
  • Then we import the required classes into MainActivity.java.
import android.widget.RelativeLayout;
import com.huawei.hms.ads.BannerAdSize;
import com.huawei.hms.ads.banner.BannerView;

Note: You can register on the Huawei Developer website with either individual or enterprise developer account. Before completing your application and publishing it on AppGalery, you need to replace the test_id with the Ad Slot Id you will receive from your enterprise developer account. You can easily register on the Huawei Developer website using the link.

  • After the BannerView is added, we call the loadAd() method of the BannerView class in MainActivity to obtain a banner ad.

When you run the project, you will see the test banner ad on the screen. Congratulations! I hope it has been a useful post :)

You can ask the problems you encounter with Huawei Mobile Services on the Huawei Developer Forum page or you can review the questions that have been answered before.

References

Click for HMS Ads Kit comprehensive guide.
Click for the HMS Ads Kit references link.
Click here for the HMS Ads Kit sample code link.
Click here for the HMS Ads Kit SDK link.

--

--