Skip to content

Explore-In-HMS/huawei.ads.imaadapter

Repository files navigation

Huawei-Ima Adapter Github Documentation

Latest Version Kotlin
Supported Platforms

Introduction

In this documentation we explained how to use Huawei-Ima Adapter in native android.

How to start?

Create an ad unit on Huawei Publisher Service

  1. Sign in to Huawei Developer Console and create an ad unit for Roll Ads.

What is IMA?

Interactive Media Ads is a suite of SDKs that make it easy to integrate multimedia ads into your apps. IMA SDKs can request ads from any Vast-compliant ad server and manage ad playback in your apps.

Developers need to create ad tags to show video ads in their application. These ad tags are unique URLs that generated by publishers from Ad Manager.

Create Ad Tag URL on Ad Manager

  1. Sign in to Google Ad Manager.
  2. Click Inventory and then Ad units.
  3. Locate and click your video ad unit.
  4. Click Generate tags.
  5. Complete the 3-step process and click Continue after each step (Tag type, Tag Options, and Tag Results)
  6. Click done.

Ad Tag URL parameters to use Adapter

A VAST ad tag URL is used by a player to retrieve video ad.

See parameters

Mandatory

output: The XML output type. VAST, VMAP.

max_ad_duration: The duration range that an ad must match. Default value (20) is used if this parameter is not set.

sz: The size of master video ad slot. Default value (640x360) is used if this parameter is not set.

Optional

vpos: Indicates whether the ad request is being sent from pre-roll, mid-roll or post-roll.

vad_type: Indicates whether a linear or non-linear ad should be returned.

npa: Indicates that the ad request should be treated as non-personalized.

tfcd: The ad request for child-directed treatment.

Integrate the Huawei Ima Adapter 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 {
    ...
    implementation 'com.github.Explore-In-HMS:huawei.ads.imaadapter:<latest_version>'
}

Version Change History

1.0-beta.1

1.0-beta

How it works?

Solution has two different uses depending on ExoPlayer creation method or the selected player.

If ExoPlayer is used and it used with MediaItem to show video content and ads, adapter solution can be choose. Initializations of adapter is as follows;

HwImaAdapter.init(SimpleExoPlayer playerInstance, String adUnitId);

or

HwImaAdapter.init(PlayerView playerInstance,String HuaweiAdUnitId);

NOTE: HwImaAdapter.init method must be called just before SimpleExoPlayer.prepare() method called.

If ExoPlayer is used and MediaItem is not used or, player that compatible with Ima Ad Tag is used, converter solution can be choose. Initialization of converter is as follows;

HwTagConverter.init(String googleImaAdTagURL, String HuaweiAdUInitId, TagConverterListener() {
    @Override
    public void onSuccess(Uri uri) {
       ...
       // SimpleExoPlayer.prepare()
       ...
    }
});

If the operation is successful, the TagConverterListener's onSuccess function returns Uri instance that contains Huawei Roll Ads. Uri object is created based on the Ad Tag URL created on the Ad Manager.

NOTE: Video and ad content must be created after the callback is successful depends on the Uri instance.

Currently, adapter supports only linear ads depends on the Huawei Vast SDK.