In this documentation we explained how to use Huawei-Smartadserver mediation.
Banner Ad | Interstitial Ad | Rewarded Ad | Native Ad | |
---|---|---|---|---|
Native (Java/Kotlin) | ✅ | ✅ | ✅ | ✅ |
- Sign in to Huawei Developer Console and create an AdUnit.
Make sure to check the article on How to show Huawei Ads with Smartadserver mediation ?
- Sign in to Smartadserver Console
- 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)
- Go to "Inventory -> Formats" and create an Ad unit for your Ad type (put 0x0 for the size and note your Format ID).
- 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)
- Select "New Insertion" inside your created campaign.
- 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"
- 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".
- On the "Creatives tab", click "Template Library", on "Offical Templates" select "In-App Mediation Custom Adapter"
- A section will be seen named "Predefined template". Give it a name, and select the ad type (Banner,Rewarded etc.)
- For the "Banner width" and "Banner height" don't write anything.
- For the "Adapter Class" and "Placement info" check the table below.
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. |
1-) Placement Info for Banner example
2-) Ad width and height values for Huawei Banner Ads :
Important Note: Only BANNER_SIZE_360_57 and BANNER_SIZE_360_144 are supported in the Chinese mainland.
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
}
}
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>'
...
}
Important: To add Huawei Ads Kit SDK and Mediation adapter, the native project should be opened with Android Studio.
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.)
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.** { *; }
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>
- 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.
First version of the Custom Adapter.
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 :
- Developers can find app level build.gradle in their project from "app-folder/app/build.gradle"
- If you use native ad format in your application, please submit a ticket here to get support from Huawei.
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.
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.
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.
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.
Banner Ad |
Interstitial Ad |
Rewarded Ad |
Native Ad |
Banner Ad |
Interstitial Ad |
Rewarded Ad |
Native Ad |