Skip to content

Explore-In-HMS/huawei.ads.openmediation_mediation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

Huawei-OpenMediation Mediation Github Documentation

Latest Version
Supported Platforms

Introduction

In this documentation we explained how to use Huawei-OpenMediation mediation plugin developed by OpenMediation. OpenMediation repository link is here

Compatibility

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

How to start?

Create an ad unit on Huawei Publisher Service

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

Create an App

  1. 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.
  2. Firstly, select  the platform of your app, and select App has been listed on a supported app store.
  3. Find your app on the selected Store.

For details, please refer to this link

Add and Manage Ad Placements

  1. 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.
  2. 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.
  3. 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

Configure Ad Instance for Ad Placement

  1. Click on "Mediation" in the left navigation bar "Setup" to go to the monetize function page.
  2. Select the placement that needs to be configured, and click "+Add Instance" in the instance sub-interface to configure instance information.
  3. 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.
  4. 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.
  5. Configure Basic Informations of Instances. Note that, Unit ID must be same with the ID you got from Huawei Ads Platform
  6. You can configure Manual eCPM for instance.
  7. Enable instances.

For details, please refer to this link

Set Mediation Rule

  1. 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.
  2. Enter basic information.
  3. Click Advanced options.
  4. Enter Advanced Options information.
  5. Enable Mediation Rule

For details, please refer to this link

Integrate the Huawei-OpenMediation Mediation SDK

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/' }   
        }
}

In the app-level build.gradle, include necessary dependencies
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'

You must add the following to your Proguard configuration file (Android Studio: proguard-rules.pro or Eclipse: proguard-project.txt) if you are using Porguard in your application. Failed to do so will lead to errors.
-dontwarn com.openmediation.sdk.**.*
-keep class com.openmediation.sdk.**{*;}

Initialization

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

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 :

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

Version Change History

2.6.5

Latest version

Platforms

Native

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 :

  1. Developers can find app level build.gradle in their project from "app-folder/app/build.gradle"
  2. If you use the 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 OpenMediation Mediation SDK. Click here to get more information about OpenMediation Mediation SDKs Banner Ad development.

Interstitial Ad

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.

Rewarded Video Ad

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.

Native Ads

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.

Unity

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

Banner Ads

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.

Interstitial Ads

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.

Rewarded Ads

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.

Step 1:

Make sure to switch to the Android Platform from Build Settings -> Android -> Switch Platform

Step 2:

Edit -> Project Settings -> Player -> Other Settings
In Other Settings set minimum API level to at least 16.

Step 3:

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.

Step 4:

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.

Step 5:

Open gradleTemplate.properties and add the following lines

android.useAndroidX=true
android.enableJetifier=true

After these configurations is completed you can display Huawei Ads.

Screenshots

banner

Banner Ad

interstitial

Interstitial Ad

Rewarded Ad

Native Ad

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published