Skip to content

Explore-In-HMS/huawei.ads.smartadsserver_mediation

Repository files navigation

Huawei-Smart Ad Server Mediation Github Documentation

Latest Version Kotlin
Supported Platforms

Introduction

In this documentation we explained how to use Huawei-Smartadserver mediation.

Compatibility

Banner Ad Interstitial Ad Rewarded Ad Native Ad
Native (Java/Kotlin)

How to start?

Create an ad unit on Huawei Publisher Service

  1. Sign in to Huawei Developer Console and create an AdUnit.

Create a mediation on Smart ad server publisher console

Make sure to check the article on How to show Huawei Ads with Smartadserver mediation ?

  1. Sign in to Smartadserver Console
  2. Go to "Inventory -> Sites & Pages" and create a site and a page for your mediation. (skip this part if you have your Smartadserver site ID and page ID)
  3. Go to "Inventory -> Formats" and create an Ad unit for your Ad type (put 0x0 for the size and note your Format ID).
  4. Go to "Campaigns -> Campaign List" and create a new campaign, (Select mediation on the pop-up,give your campaign a name and an expiration date)
  5. Select "New Insertion" inside your created campaign.
  6. Switch to classical mode UI from left side of the web page, give your insertion a name, select "Mobile" as category, select "AdNetwork / Mediation" as channel and select "Pay Ads" for the type. Select other fields according to your needs and click "Save and Go to Next Step"
  7. On the "Placement tab", select your ad unit that is created on the step-3, and select the site and page that are created on the step-2. Click "Save and Go to Next Step".
  8. On the "Creatives tab", click "Template Library", on "Offical Templates" select "In-App Mediation Custom Adapter"
  9. A section will be seen named "Predefined template". Give it a name, and select the ad type (Banner,Rewarded etc.)
  10. For the "Banner width" and "Banner height" don't write anything.
  11. For the "Adapter Class" and "Placement info" check the table below.

Custom Data for the Huawei Adapter (Predefined template)

Ad Types Banner Ad Interstitial Ad Rewarded Ad Native Ad
Adapter Class com.hmscl.huawei.smart_mediation.SASHuaweiBannerAdapter com.hmscl.huawei.smart_mediation.SASHuaweiInterstitialAdapter com.hmscl.huawei.smart_mediation.SASHuaweiRewardedVideoAdapter com.hmscl.huawei.smart_mediation.SASHuaweiNativeAdapter
Placement info Write the Huawei Ad unit ID,banner width and banner height (sepetate them with ",") Write the Huawei Ad unit ID with no spaces. Write the Huawei Ad unit ID with no spaces. Write the Huawei Ad unit ID with no spaces.

Custom Data Details for Banner Ads

1-) Placement Info for Banner example

placementinfoPNG

2-) Ad width and height values for Huawei Banner Ads :

banner_size

Important Note: Only BANNER_SIZE_360_57 and BANNER_SIZE_360_144 are supported in the Chinese mainland.

Integrate the Huawei Ads SDK

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/' } // Add this line
    maven {url "https://jitpack.io"} // Add this line
}

...

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

In the app-level build.gradle, include Huawei Ads dependency (required by the adapter) and the adapter
dependencies {
    //Huawei Ads Prime
    implementation 'com.huawei.hms:ads-prime:<latest_version>'
    //Adapter SDK
    implementation 'com.github.Explore-In-HMS:huawei.ads.smartadsserver_mediation:<latest_version>'
   
    // Optional : add Smart support library for Huawei devices 
    implementation 'com.smartadserver.android:smart-core-sdk-huawei-support:1.0.0'
}

NOTE: If your app can run only on Huawei mobile phones, you can integrate the Huawei Ads Lite SDK instead of Huawei Ads SDK (Optional)

dependencies {
    //Huawei Ads Lite
    implementation 'com.huawei.hms:ads-lite:<latest_version>'
    ...
}

Latest version of SDKs

Important: To add Huawei Ads Kit SDK and Mediation adapter, the native project should be opened with Android Studio.

Permissions

The HUAWEI Ads SDK (com.huawei.hms:ads) has integrated the required permissions. Therefore, you do not need to apply for these permissions.

android.permission.ACCESS_NETWORK_STATE: Checks whether the current network is available.

android.permission.ACCESS_WIFI_STATE: Obtains the current Wi-Fi connection status and the information about WLAN hotspots.

android.permission.BLUETOOTH: Obtains the statuses of paired Bluetooth devices. (The permission can be removed if not necessary.)

android.permission.CAMERA: Displays AR ads in the Camera app. (The permission can be removed if not necessary.)

android.permission.READ_CALENDAR: Reads calendar events and their subscription statuses. (The permission can be removed if not necessary.)

android.permission.WRITE_CALENDAR: Creates a calendar event when a user clicks the subscription button in an ad. (The permission can be removed if not necessary.)

Configuring Obfuscation Scripts

Before building the APK, configure the obfuscation configuration file to prevent the HUAWEI Ads SDK () from being obfuscated.

Open the obfuscation configuration file proguard-rules.pro in the app-level directory of your Android project, and add configurations to exclude the HUAWEI Ads SDK from obfuscation.

-keep class com.huawei.openalliance.ad.** { *; }
-keep class com.huawei.hms.ads.** { *; }

Configuring Network Permissions

To allow HTTP and HTTPS network requests on devices with targetSdkVersion 28 or later, configure the following information in the AndroidManifest.xml file (not adding it might effect rewarded ad mediation):

<application
    ...
    android:usesCleartextTraffic="true"
    >
    ...
</application>

Version Change History

1.0.1

  • Integration methods of Huawei Ads SDK in the plugin have been changed to compileOnly.
  • Huawei Ads SDK (lite or prime) has to be added externally to the app anymore.

1.0.0

First version of the Custom Adapter.

Platforms

Native Android

This section demonstrates how to use smartadserver mediation feature with Huawei Ads Kit on Native android app.

Make sure to check the article on (edit after medium) How to use Huawei Ads with AdMob mediation (Native Android)

Firstly, integrate the Display SDK for Android

Smartadserver Android Display SDK can be used for all ad types.

Note :

  1. Developers can find app level build.gradle in their project from "app-folder/app/build.gradle"
  2. If you use native ad format in your application, please submit a ticket here to get support from Huawei.

Banner Ad

To use Banner ads in Native android apps, please check the Display SDK. Click here to get more information about Display SDKs Banner Ad development.

Interstitial Ad

To use Interstitial ads in Native android apps, please check the Display SDK. Click here to get more information about Display SDKs Interstitial Ad development.

Rewarded Ad

To use Rewarded ads in Native android Rewarded, please check the Display SDK. Click here to get more information about Display SDKs Banner Ad development.

Native Ads

To use Native ads in Native android apps, please check the Display SDK. Click here to get more information about Display SDKs Native Ad development.

Note: Click here to check the Smartadserver's offical demo project.

Screenshots

Smartadserver

Banner Ad

Interstitial Ad

Rewarded Ad

Native Ad

Huawei

Banner Ad

Interstitial Ad

Rewarded Ad

Native Ad