In this documentation we explained how to use Huawei-OpenMediation mediation plugin developed by OpenMediation. OpenMediation repository link is here
Banner Ad | Interstitial Ad | Rewarded Video Ad | Native Ad | |
---|---|---|---|---|
Native (Java/Kotlin) | ✅ | ✅ | ✅ | ✅ |
Unity | ✅ | ✅ | ✅ | ❌ |
- Sign in to Huawei Developer Console and create an AdUnit
- Log in to OpenMediation and navigate to the Overview interface. You will see "Add App" at the top of the application list, click to start adding an APP.
- Firstly, select the platform of your app, and select App has been listed on a supported app store.
- Find your app on the selected Store.
For details, please refer to this link
- The placement needs to match the added application, and you need to select the corresponding app in the application list of "Overview". After entering Monetize, click "Setup", click "Placement" in the navigation bar, and click "Add Placement" to add placement.
- After customizing the name of the placement in the Name column, select the ad type you want and click Save on the top of the page.
- In the Operations section, you can control the status of each placements, "Enable" or "Disable".
NOTE: Only one rewarded and interstitial placement is allowed to be created in the OpenMediation platform. Multi-ad scene requirements can be implemented by automatically calling logic and scene functions through the OpenMediation SDK.So, after perfom the adding placement steps for Rewarded and Interstitial Ads, you can also add Placement Scenes for them. For details about the Scenes please refer to this link.
For details, please refer to this link
- Click on "Mediation" in the left navigation bar "Setup" to go to the monetize function page.
- Select the placement that needs to be configured, and click "+Add Instance" in the instance sub-interface to configure instance information.
- You can get the ad network drop-down menu by clicking on the "Ad Network", and then click to select the Huawei Ads ad network.
- When you click on the ad network list to select Huawei Ads, you'll see a list of instance additions, which you can start configuring by clicking on.
- Configure Basic Informations of Instances. Note that, Unit ID must be same with the ID you got from Huawei Ads Platform
- You can configure Manual eCPM for instance.
- Enable instances.
For details, please refer to this link
- In the Setup>Mediation Tab, select the placement that needs to be configured, and click "+Add Mediation Rule" in the "Mediation Rule" sub-interface to configure mediation rule.
- Enter basic information.
- Click Advanced options.
- Enter Advanced Options information.
- Enable Mediation Rule
For details, please refer to this link
In the project-level build.gradle, include necessary Maven repositories.
allprojects {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/’}
maven { url 'https://dl.openmediation.com/omcenter/' }
}
}
implementation 'com.openmediation:test-suite:2.0.2’
implementation 'com.huawei.hms:ads-prime:3.4.56.302’
implementation 'com.openmediation.adapters:hwads:2.6.0@aar'
implementation 'com.openmediation:om-android-sdk:2.6.5@aar'
-dontwarn com.openmediation.sdk.**.*
-keep class com.openmediation.sdk.**{*;}
Before you can fetch ads from OpenMediation Platform, you should first initialize the OpenMediation SDK when your app started. To do so, we suggest to call OpenMediation SDK's init() method within onCreate() of an Application or Activity as below:
import com.openmediation.sdk.InitConfiguration;
import com.openmediation.sdk.OmAds;
import com.openmediation.sdk.InitCallback;
import com.openmediation.sdk.utils.error.Error;
...
InitConfiguration configuration = new InitConfiguration.Builder()
.appKey("Your AppKey")
.logEnable(false)
.build();
OmAds.init(configuration, new InitCallback() {
// Invoked when the initialization is successful.
@Override
public void onSuccess() {
}
// Invoked when the initialization is failed.
@Override
public void onError(Error message) {
}
});
NOTE: "APP KEY" can only be obtained by creating apps on OpenMediation
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 :
<activity
...
android:usesCleartextTraffic="true"
>
...
</activity>
Latest version
This section demonstrates how to use OpenMediation mediation feature with Huawei Ads Kit on Native android app.
Firstly, integrate the OpenMediation Mediation SDK for Android
OpenMediation Mediation 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 the 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 OpenMediation Mediation SDK. Click here to get more information about OpenMediation Mediation SDKs Banner Ad development.
To use Interstitial ads in Native android apps, please check the OpenMediation Mediation SDK. Click here to get more information about OpenMediation Mediation SDKs Interstitial Ad development.
To use Rewarded Video ads in Native android apps, please check the OpenMediation Mediation SDK. Click here to get more information about OpenMediation Mediation SDKs Rewarded Ad development.
To use Native ads in Native android apps, please check the OpenMediation Mediation SDK. Click here to get more information about OpenMediation Mediation SDKs Native Ad development.
This section demonstrates how to use OpenMediation feature with Huawei Ads Kit on Unity.
Make sure to check the article on How to use Huawei Ads with Supported Ad Platforms in Unity ?
Supported Ad Formats are: Banner Ads, Interstitial Ads and Rewarded Ads.
Firstly, integrate the OpenMediation Unity Plugin to Unity.
For more details on OpenMediation Unity Plugin visit here
To use Banner ads in Unity , please check the OpenMediation Unity Plugin. Click here to get more information about OpenMediation Unity Plugin Banner Ad development.
To use Interstitial ads in Unity, please check the OpenMediation Unity Plugin. Click here to get more information about OpenMediation Unity Plugin Interstitial Ad development.
To use Rewarded ads in Unity, please check the OpenMediation Unity Plugin. Click here to get more information about OpenMediation Unity Plugin Banner Ad development.
Make sure to switch to the Android Platform from Build Settings -> Android -> Switch Platform
Edit -> Project Settings -> Player -> Other Settings
In Other Settings set minimum API level to at least 16.
Edit -> Project Settings -> Player -> Publishing Settings
In Publishing Settings select “Custom Main Gradle Template” , “Custom Base Gradle Template” and “Custom Greadle Properties Template”
This will let you override mainTemplate.gradle , baseProjectTemplate.gradle and gradleTemplate.properties files in the project.
baseProjectTemplate.gradle is equal to project-level gradle so you have to include Huawei's Maven repositories from the Integrate the Huawei Mediation SDK section from here.
mainTemplate.gradle is equal to app-level build.gradle so you have to include dependencies from the Integrate the Huawei Mediation SDK section from here.
Open gradleTemplate.properties and add the following lines
android.useAndroidX=true
android.enableJetifier=true
After these configurations is completed you can display Huawei Ads.
Banner Ad |
Interstitial Ad |
Rewarded Ad |
Native Ad |