Native Ads

"Get a comprehensive guide on implementing native ads in the HMS Unity Plugin with the Ads Kit.

Using Native Ads Prefab

  1. Enable Ads kit from kit settings.

  2. Find the prefab in Assets>Huawei>Prefabs>native_large_image.

  3. Drag and drop the prefab onto the canvas in your scene. (Do not modify the prefab. If necessary, you can duplicate the prefab to the out of the Huawei folder.)

  4. Edit Ad Unit ID with your Ad Unit ID.

That's it:)

Creating a Native Ad In Your Own

Just a reminder: you can create different things with the native ad but please first read the policies and rules carefully. Publisher Behavioral Policies

1- Build a NativeAdLoader object.

The NativeAdLoader class provides the NativeAdLoader.Builder class for setting the ad unit ID, customizing attributes, and building the NativeAdLoader object. The sample code is as follows:

2- Load an ad.

NativeAdLoader provides the loadAd() and loadAds() methods for ad loading.

  • loadAd() for loading a single native adAdParam is the only parameter. After loadAd() is called, the listener receives a callback on success or failure. The sample code is as follows:

nativeAdLoader.LoadAd(new AdParam.Builder().Build());
  • loadAds() for loading multiple native ads

loadAds() contains two parameters: AdParam and maxAdsNum (maximum value: 5). After you set maxAdsNum, the number of ads returned by the SDK will be less than or equal to the requested number. The sample code is as follows:

nativeAdLoader.LoadAds(new AdParam.Builder().Build(), 5);

After ads are loaded successfully, the SDK calls the onNativeAdLoaded() method of NativeAd.NativeAdLoadedListener multiple times to return a NativeAd object each time. After all ads are returned, the SDK calls the onAdLoaded() method of AdStatusListener to send a request success notification. If ads fail to be loaded, the SDK calls the onAdFailed() method of AdStatusListener. The sample code is as follows:

3- Display a native ad.

After a native ad is loaded, you need to display it in the listener callback method. The "Why this ad" icon (i) or "Dislike this ad" icon (x), and the ad flag must be displayed in the corner of each ad view.

NOTE

Use either of the following methods:

Method 1: If you want to display the Hide ad and Why am I seeing this ad buttons after users click the x icon, you do not need to set the i icon.

Method 2: If you want the ad to be directly closed after users click the x icon, you will need to set the i icon along with the x icon.

a- Create a layout

Large_Image_Native example:

ad_media: The game object that has <Raw Image> to show ad media from the URL.

ad_title: The game object that has <Text> to show ad title. (at least 44 characters are reserved check the policy)

ad_source: The game object that has <Text> to show the source of the Ad.

ad_flag: The flag used to indicate to users that this part is an advertisement. It is mandatory and Make sure it is visible.

click_catcher: An invisible button that takes up the entire ad. It is not mandatory but can be used to increase your income. It should not go beyond the ad and should not block other buttons.

ad_call_to_action: The button of the native Ad we loaded.

why_this_ad: The Button that takes users to the site explaining why they saw this ad.

b- Display a Native Ad

For more information please refer to:

Last updated