Skip to main content

4.1 Admob Adapter

Note: Due to internal logic limitations of the Google Ads SDK, offline scenario traffic cannot be forwarded to the Hisavana SDK via the adapter. If you wish to use Hisavana's offline capabilities, it is recommended that you integrate the Hisavana SDK directly.

4.1.1 Version Release History

VersionRelease DateUpdates
3.1.9.12025-03-10Depends on Hisavana SDK version 3.1.9.1; Upgraded google play-services-ads version to 22.0.0
2.2.0.22023-02-24Fixed the issue of no click callback for native ads
2.0.1.22022-09-02Initial version release

4.1.2 Adding Custom Events in the AdMob UI.

  1. On the homepage, click the left sidebar - Mediation, select 'Add Mediation Group' in the middle, and follow the prompts to proceed with subsequent operations.

  2. On the Add Mediation Group interface - under the Ad Sources - 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

Versions before 3.1.9.1: com.hisavana.admob.adapter.SampleAdapter

Parameter:

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

4.1.3 Importing the Adapter SDK into the Project

First, add the maven remote repository URL to the project-level build.gradle file, as shown below:

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();

// Hisavana Adapter initialization. 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 Using Google Ads API to Request Ads

(Omitted)