Extend your Advertisement with HMS Ads Kit: Splash Ad in Unity!

Samet Güzel
Huawei Developers - Türkiye
5 min readNov 18, 2021
Photo by ChipOnline

📖 Introduction 📖

This article will show how to implement HMS Unity Plugin into your project and get started with Huawei Ads Kit with Splash Ads!

I’ll be guiding you on how to configure Splash Ad for your Unity project.

🚧 Getting Started 🚧

First, we need to create a project on AGC which is explained here. After that, we need to install the appropriate Unity package depending on our Unity version. You can find released versions here. I’ll be using the current latest version which is v2.0.13 for my Unity 2020 version. As a final step before configuring, we need to import HMS Unity Plugin into our project explained here.

✨ Enabling Ads Kit ✨

First, let’s enable Ads Kit in our Unity project. Go to “Huawei” and select “Kit Settings” from menu items. Make sure to check the “Enable Plugin” and “Ads” checkboxes to enable the plugin and Ads Kit. Tada! You’ve enabled the plugin and Ads Kit!

Enabling plugin and Ads Kit

💻 Enabling Splash Ad💻

We’ve successfully enabled Ads Kit for our project. Let’s configure the Splash Ad!

When we click on the “Ads” checkbox, a new tab will appear as “Ads” where we can configure Ads Kit. Right now, the plugin is supporting four ad types. Banner, Interstitial, Rewarded, and Splash Ads. Right now we will focus on configuring Splash Ads. Let’s click on “Enable Splash Ads” to enable Splash Ad for our project and configure! I suggest checking “Use Test Ads” below to test your Splash Ads with Test Ads.

Ads Settings

⌨️ Configuring Splash Ad⌨️

After enabling Splash Ads, the bottom section will become enable for us to configure. I’ll be explaining the configuration for each item below.

Splash Ad Settings
  1. Splash Ad ID: This section is for the Ad Id that we obtain from Huawei Ads Publisher Service. (Don’t need to fill if using test ads.)
  2. Orientation: Orientation for the Splash Ad. Can be Portrait or Landscape.
  3. Splash Title: This will be the title that will be shown in Splash Ad. (Default will be called “Splash Title” if empty.)
  4. Splash Sub Text: This will be the subtext that appears below the title. Usually, the “Copyright” text goes here. (Default will be called “Splash Subtext” if empty.)
  5. Icon: This will be the icon that will be shown in Splash Ad. The icon will be 28x28 pixels when it is shown on Splash Ad.

We also have a button called “Preview” to preview the Splash Ad that will be shown to users! This button will create a GameObject inside Unity Editor for developers to visualize their Splash Ad to see how it will look before building the app.

🚧 Restrictions for the Icon Image🚧

Unfortunately, the Icon image has some conditions to meet. First, make sure to check “Read/Write Enabled” for the plugin to read the image.

Icon Image Properties

After that, please check that the image is not compressed. If you are using the default platform, please set Compression to None.

Image Compression

If you are overriding for the Android platform, please check that the Format is not a Compressed one.

Image Format

💡 Preview your Splash Ad 💡

The plugin lets you preview your Splash Ad before building the app!

Just simply clicking on the “Preview” button will create an object in the scene to preview your Splash Ad with your settings.

Splash Settings

After clicking on the “Preview” button, you will see a new GameObject getting created and the “Preview” button will be renamed as “Close Preview” to close the preview.

Preview Scene

There is also an opportunity to test on a real device!

The demo scene for Ads Kit contains “Splash Image” and “Splash Video” buttons which make a request and show the Splash even though it is not starting of an app.

Ads Demo Scene

Don’t worry if you are getting Error Code 3 in the process, sometimes it fails if it is loading for the first time.

⌨️ Coding ⌨️

There is no need for any coding if you don’t want to subscribe to the callbacks of the Splash Ad. The plugin will automatically show the Splash Ad on Start after Unity’s Splash finishes.

But there are some callbacks that you can subscribe to. They are listed below.

  • OnSplashAdDismissed
  • OnSplashAdFailedToLoad
  • OnSplashAdLoaded
  • OnSplashAdClicked
  • OnSplashAdShowed

These callbacks won’t be called from Unity’s main thread. Please be careful about usage of any Unity API related methods here.

Subscribing into these callbacks is easy to do. But since Splash Ad needs to start right after Unity’s Splash, it needs to run in the Awake method. That means you also need to subscribe to these callbacks in one of your Monobehaviour’s Awake methods. Follow the code listed below for how to subscribe to Splash Ad callbacks as an example.

HMSAdsKitManager.Instance.OnSplashAdClicked += OnSplashAdClicked;private void OnSplashAdClicked(){     Debug.Log("SplashAdClicked.");}

💡 Conclusion 💡

We learned how to create projects on AGC, implement HMS Unity Plugin, and enable/use Ads Kit with Splash Ad.

I hope this article has shown the configuration of Splash Ad and boosted your advertisement to the next level!

Don’t hesitate to ask questions.

👇 References 👇

--

--