In this documentation we explained how to use Huawei-Smaato mediation with in the different platforms.
Banner Ad | Interstitial Ad | |
---|---|---|
Native (Java/Kotlin) | ✅ | ✅ |
- Sign in to [Huawei Developer Console] (https://developer.huawei.com/consumer/en/console) and create an AdUnit
- Sign in to [Smaato console] (https://accounts.smaato.com/)
- Go to "**Inventory -> Create a new App"
- Under the "Apps" section, click "New Adspace" Give it a label (eg: Huawei Banner) click "Save"
- Go to "**Networks -> Create a new Network" and choose Custom SDK Network
- Click New Line Item for add mediation
- Enter the **Class Name and Method Name ** and Custom Data according to the type of your Ad. Refer to the section below.
Ad Type | Custom event class |
---|---|
Banner Ad | com.hmscl.huawei.smaato_mediation.CustomMediationBanner |
Interstitial Ad | com.hmscl.huawei.smaato_mediation.CustomMediationIntersitial |
{"AD_UNIT_ID":"testw6vs28auh3"}
loadCustomBanner
loadCustomIntersitial
Note : A device with Huawei Mobile Services (HMS) installed is required
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
}
...
allprojects {
repositories {
google()
jcenter() // Also, make sure jcenter() is included
maven { url 'https://developer.huawei.com/repo/' } //Add this line
}
}
First, download the "smaato_mediation-v1.0.1.aar" file in the project. Then in Android Studio, after saying File->New->New Module, select Import AAR&JAR. Then select the downloaded aar file
Note : Older versions could be found under the "_releases" folder
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//Adapter SDK
implementation project(":smaato_mediation-v1.0.1")
//Huawei Ads Prime
implementation 'com.huawei.hms:ads-prime:<latest_version>'
}
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.)
- 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.
This section demonstrates how to use Smaato mediation feature with Huawei Ads Kit on Native android app.
Firstly, integrate the Smaato SDK for Android
Smaato Android 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 Smaato SDK. Click here to get more information about Smaato SDKs Banner Ad development.
To use Interstitial ads in Native android apps, please check the Smaato SDK. Click here to get more information about Smaato SDKs Interstitial Ad development.
<SmaatoBanner
adSize="fullBanner"
BannerView mBanner = new BannerView (context);
mBanner.getAdSettings().setPublisherId(publisherId);
mBanner.getAdSettings().setAdspaceId(adspaceId);} />
interstitial = new Interstitial(this); //'this' is your Context
interstitial.setInterstitialAdListener(interstitialAdListener);
interstitial.getAdSettings().setPublisherId(your_publisher_id);
interstitial.getAdSettings().setAdspaceId(your_adspace_d);
Banner Ad |
Banner Ad |
Interstitial Ad |