Skip to main content

4.1 Admob Adapter

Note: Due to internal logic limitations of the Google Ads SDK, offline traffic cannot be forwarded to the Hisavana SDK through the adapter. If you wish to utilize the offline capabilities of the Hisavana, it is recommended to integrate the Hisavana SDK directly.

4.1.1 Version Release History

VersionRelease DateUpdates
3.1.9.12025-03-101. Depends on Hisavana 3.1.9.1; 2. Upgrades google play-services-ads to version 22.0.0。
2.2.0.22023-02-24Fixes the issue of no click callback for native ads
2.0.1.22022-09-02Initial release

4.1.2 Adding Custom Events in the AdMob Interface

  1. On the homepage, click the left sidebar - Mediation, and select "Add Mediation Group" in the middle, then follow the prompts to complete the operation.

  2. In the "Add Mediation Group" interface - under "Ad Source" - "Waterfall" path, click Add Custom Event.

  3. Add Ad Unit Mapping

Class Name:

Version 3.1.9.1 and later: com.hisavana.admob.adapter.HisavanaAdapter

Before version 3.1.9.1: com.hisavana.admob.adapter.SampleAdapter

Parameter:

Enter the Ad Unit ID applied for in the Hisavana backend.

4.1.3 Integrate the Adapter SDK in the Project

First, add Maven remote dependency addresses in the project-level build.gradle file as follows:

buildscript { 
repositories {
maven { url "https://mvn.shalltry.com/repository/maven-public/" }
maven { url "https://mvn.shalltry.com/repository/ad-releases/" }
}
}

allprojects {
repositories {
maven { url "https://mvn.shalltry.com/repository/maven-public/" }
maven { url "https://mvn.shalltry.com/repository/ad-releases/" }
}
}

Then, introduce the admob adapter package in the Module's build.gradle:

implementation "com.cloud.hisavana.sdk.ssp.adapter:admob:3.1.9.1"
implementation "com.google.android.gms:play-services-ads:22.0.0"

4.1.4 SDK initialization configuration

public class MyApplication extends Application {

@Override
public void onCreate() {
super.onCreate();

// Initialize Hisavana Adapter. Constants.hisavanaAppId is the AppId applied for in the Hisavana backend.
HisavanaManager.setAppId(Constants.hisavanaAppId);

// Google ads initialization.
MobileAds.initialize(this.getApplicationContext(), initializationStatus -> {
Log.d("MobileAds", "Init status: " + initializationStatus.toString());
});
}
}

4.1.5 Use Google Ads API to Request Ads

Omitted