mediation-adapters | AdMob Adaptor Android SDK Integration Guide

Introduction

The InMobi adapter for AdMob allows publishers to integrate with InMobi via the AdMob mediation platform. The adapter functions as a bridge between the AdMob mediation SDK and the InMobi SDK. For more information about AdMob Mediation platform, see AdMob Help pages.

Requirements

Creating a Google Account

You need to have a Google account to sign up for an AdMob account. If you already have a Google or an AdMob account, you can skip this step. This step is a one time action.

Ad Formats Supported

You can get the following ad types from InMobi via AdMob mediations. You can click the link below to view the integration instructions for the respective ad types.

Integrating with Banner Ads

To specify an adapter using the AdMob web user interface, complete the following steps:

  1. Log on to your AdMob account.
  2. Click the Monetize tab, and then select Monetize new app.

  3. Register your Android app.

  4. Select Banner as ad format for monetization.

  5. Once you create the ad unit, AdMob will generate an “Ad Unit ID”. Please make a note of this ID.
  6. Under Mediation, select Ad Sources.
  7. Select New Ad Network, and then add InMobi as ad source.

  8. In the Network Settings page for InMobi, insert your InMobi account and placement id (Only for SDK > 5.0.0).

  9. AdMob can pull publisher reporting data automatically for automatic eCPM optimization. For this, the publisher must provide their InMobi reporting API credentials in the AdMob UI.
    To enable Ad Network optimization, select the Automatically pull the eCPM value from this ad network check box, and then enter your InMobi login credentials.
    Please contact InMobi support to generate the secret key required for this feature.

Integrating with Interstitial Ads

To specify an adapter using the AdMob web user interface, complete the following steps:

  1. Log on to your AdMob account.
  2. Click the Monetize tab, and then select Monetize new app.

  3. Register your Android app.

  4. Select Interstitial as ad format for monetization.

  5. Once you create the ad unit, AdMob will generate an “Ad Unit ID”. Please make a note of this ID.
  6. Under Mediation, select Ad Sources.
  7. Select New Ad Network, and then add InMobi as ad source.

  8. In the Network Settings page for InMobi, insert your InMobi account and placement id (Only for SDK > 5.0.0).

  9. AdMob can pull publisher reporting data automatically for automatic eCPM optimization. For this, the publisher must provide their InMobi reporting API credentials in the AdMob UI.
    To enable Ad Network optimization, select the Automatically pull the eCPM value from this ad network check box, and then enter your InMobi login credentials.
    Please contact InMobi support to generate the secret key required for this feature.

Integrating with Rewarded Interstitial Ads

To specify an adapter using the AdMob web user interface, complete the following steps:

  1. Log on to your AdMob account.
  2. Click the Monetize tab, and then select Monetize new app.

  3. Register your Android app.

  4. Select Rewarded Interstitial as ad format for monetization.

  5. Publisher can opt to take a reward either from third party ad network like InMobi or from AdMob itself.
    If the publisher opts for “Use third-party ad network settings”, AdMob will pass back the reward set up by them on InMobi dashboard, otherwise publisher will be asked to set up a reward on AdMob.
  6. While setting up the rewards on InMobi dashboard, please make sure the reward value is in the form of Integer.
  7. Once you create the ad unit, AdMob will generate an “Ad Unit ID”. Please make a note of this ID.
  8. Under Mediation, select Ad Sources.
  9. Select New Ad Network, and then add InMobi as ad source.

  10. In the Network Settings page for InMobi, insert your InMobi account and placement id (Only for SDK > 5.0.0).

  11. AdMob can pull publisher reporting data automatically for automatic eCPM optimization. For this, the publisher must provide their InMobi reporting API credentials in the AdMob UI.
    To enable Ad Network optimization, select the Automatically pull the eCPM value from this ad network check box, and then enter your InMobi login credentials.
    Please contact InMobi support to generate the secret key required for this feature.

Integrating with Native Ads

Native Mediation is only supported for AdMob Native Advanced functionality. To specify an adapter using the AdMob web user interface, complete the following steps:

  1. Log on to your AdMob account.
  2. Click the Monetize tab, and then select Monetize new app.

  3. Register your Android app.

  4. Select Native as ad format for monetization, and then switch to Native Ads Advanced.

  5. Name the ad unit for native.

  6. Under Mediation, select Ad Sources.
  7. Select New Ad Network, and then add InMobi as ad source.

  8. In the Network Settings page for InMobi, insert your InMobi account and placement id (Only for SDK > 5.0.0).

  9. AdMob can pull publisher reporting data automatically for automatic eCPM optimization. For this, the publisher must provide their InMobi reporting API credentials in the AdMob UI.
    To enable Ad Network optimization, select the Automatically pull the eCPM value from this ad network check box, and then enter your InMobi login credentials.
    Please contact InMobi support to generate the secret key required for this feature.

Note: When integrating InMobi via AdMob, you must keep in mind the following key points:

  • While creating native placements on InMobi dashboard, please make sure the key names are not changed.
  • InMobi supports only App Install ads and NO content ads. Publisher need to be careful while requesting ads from InMobi via AdMob. Please reach out to your Partner Manager to enable this setting.
  • InMobi Adapter doesn’t honor shouldRequestMultipleImages flag of AdMob SDK. So adapter doesn’t support multiple images.
  • InMobi Adapter doesn’t honor getImageOrientation/preferredImageOrientation flag of AdMob SDK.
  • Refer to Demographic Section on how to pass the extra parameters in the form of dictionary.

Integrating with InMobi SDK

Changes to AndroidManifest XML File

To use the InMobi SDK, please modify your manifest file with the following instructions:

Google Play Services

The InMobi Android SDK requires the Google Play Services (4.0 or later) library to function. This is to comply with the Google Play content guidelines for collecting the advertising identifier.
Please see here for more information.
Include the below within the <application> tag.

<meta-data android:name="com.google.android.gms.version" 
android:value="@integer/google_play_services_version" />
		

Mandatory Activities

Ensure that you add the com.inmobi.rendering.InMobiAdActivity activity file to your manifest XML, within the <application> tag. This activity will be used to open ads in the embedded browser, and to display interstitial ads.

<activity
android:name="com.inmobi.rendering.InMobiAdActivity"
android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize"
android:hardwareAccelerated="true" />
		

Mandatory Permissions

Ensure that you add the INTERNET and ACCESS_NETWORK_STATE permissions to your XML file just before the closing </manifest> tag.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" 
/>
		

Recommended Permissions

Ensure that you add the permissions to your xml file just before the closing </manifest> tag:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION"/>
<uses-permission android:name="android.permission.READ_CALENDAR"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
		

The InMobi SDK requires these permissions to enable certain Rich Media capabilities. For more information about why these permissions are needed, see Support Portal.

Add the following permission for Google ads:

<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
		

After changing the AndroidManifest.xml file, complete the following steps:

  1. Add the adapter library and the InMobi SDK into the libs folder of your Android project.
  2. Enable InMobi as ad network in AdMob Mediation UI as shown above.
  3. Make ad requests normally using the AdMob SDK. However, use the mediation/ad unit ID for placement, instead of the publisher ID.
  4. Note: InMobi only supports fixed-size ad units; Smart banners are not supported by InMobi. As such, requests for smart banners will not be sent to the InMobi network, resulting in a difference of request counts.
    To integrate with InMobi, please create an ad unit of fixed size.

ProGuard and the InMobi SDK

Add the below ProGuard configuration. It is required as InMobi uses reflection to invoke Google Play Service methods. For more information about validating your integration with Google Play Services, see here.

-keep class com.google.android.gms.common.api.GoogleApiClient { public *; }
-keep class com.google.android.gms.common.api.GoogleApiClient$* {public *;}
-keep class com.google.android.gms.location.LocationServices {public *;}
-keep class com.google.android.gms.location.FusedLocationProviderApi {public *;}
-keep class com.google.android.gms.location.ActivityRecognition {public *;}
-keep class com.google.android.gms.location.ActivityRecognitionApi {public *;}
-keep class com.google.android.gms.location.ActivityRecognitionResult {public *;}
-keep class com.google.android.gms.location.DetectedActivity {public *;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient{public *;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info{public *;}
		

Note: InMobi Android SDK 4.0 is already obfuscated, shrunk, and optimized using ProGuard. If you are running ProGuard on your Android application, ensure that the following directive is added in your ProGuard configuration file:

-keepattributes SourceFile,LineNumberTable,InnerClasses
-keep class com.inmobi.** { *; }
-dontwarn com.inmobi.**
-dontwarn com.google.android.gms**
		

Passing User Location and Demographic Data

Passing User Location

Location information can be passed in the mediation ad request object by calling the setLocation() API of MediationAdRequest class of the AdMob SDK.
InMobi highly recommends passing location data to enable richer targeting ads for monetization.

Passing User Demographic

All non-context specific parameters can be passed to InMobi for richer ad targeting. Since our adapter is compliant with V2 of AdMob SDK, demographic parameters need to be passed in bundle object.
InMobi supports the following parameters to be passed in the bundle key and its possible values:

Key Name

Value

Description

InMobiNetworkKeys.AGE_GROUP InMobiNetworkValues.ABOVE_55,
InMobiNetworkValues.BELOW_18,
InMobiNetworkValues.BETWEEN_18_AND_20,
InMobiNetworkValues.BETWEEN_25_AND_34,
InMobiNetworkValues.BETWEEN_35_AND_54,
InMobiNetworkValues.BETWEEN_21_AND_24
The age group of the user

InMobiNetworkKeys.HOUSEHOLD_INCOME

InMobiNetworkValues.ABOVE_USD_150K,
InMobiNetworkValues.BELOW_USD_5K,
InMobiNetworkValues.BETWEEN_USD_100K_AND_150K,
InMobiNetworkValues.BETWEEN_USD_10K_AND_15K,
InMobiNetworkValues.BETWEEN_USD_15K_AND_20K,
InMobiNetworkValues.BETWEEN_USD_20K_AND_25K,
InMobiNetworkValues.BETWEEN_USD_25K_AND_50K,
InMobiNetworkValues.BETWEEN_USD_50K_AND_75K,
InMobiNetworkValues.BETWEEN_USD_5K_AND_10K,
InMobiNetworkValues.BETWEEN_USD_75K_AND_100K

The house hold income of user in US Dollars

InMobiNetworkKeys.EDUCATION

InMobiNetworkValues.EDUCATION_HIGHSCHOOLORLESS,
InMobiNetworkValues.EDUCATION_COLLEGEORGRADUATE,
InMobiNetworkValues.EDUCATION_POSTGRADUATEORABOVE

The education level

  • High school, or less
  • College, or graduate
  • Postgraduate, or above

InMobiNetworkKeys.ETHNICITY

InMobiNetworkValues.ETHNICITY_ASIAN,
InMobiNetworkValues.ETHNICITY_HISPANIC,
InMobiNetworkValues.ETHNICITY_AFRICAN_AMERICAN,
InMobiNetworkValues.ETHNICITY_CAUCASIAN,
InMobiNetworkValues.ETHNICITY_OTHER

Ethnic group of the user

  • Asian
  • Hispanic
  • Africanamerican
  • Caucasian
  • Other

InMobiNetworkKeys.INCOME

Any String

Approximate annual household income (in US Dollars)

InMobiNetworkKeys.AGE

Any String

The age of the user

InMobiNetworkKeys.INTERESTS

Any String

Any additional relevant description of the user, or their preferences, separated by commas. Valid acceptable values are mentioned below

InMobiNetworkKeys.POSTAL_CODE

Any String

The postal code (usually a 5 digit number)

InMobiNetworkKeys.AREA_CODE

Any String

The area code (part of the telephone number)

InMobiNetworkKeys.LANGUAGE

Any String

The native language of the user (if known)

InMobiNetworkKeys.NATIONALITY

Any String

Nationality of the user

InMobiNetworkKeys.ImIdType_LOGIN

InMobiNetworkValues.ImIdType_LOGIN

Indicates a login ID in the publisher’s domain

InMobiNetworkKeys.ImIdType_SESSION

InMobiNetworkValues.ImIdType_SESSION

Indicates a session ID in the publisher’s domain

InMobiNetworkKeys.CITY

Any String

City

InMobiNetworkKeys.STATE

Any String

State

InMobiNetworkKeys.COUNTRY

Any String

Country

InMobiNetworkKeys.LOGLEVEL

InMobiNetworkValues.LOGLEVEL_NONE,
InMobiNetworkValues.LOGLEVEL_DEBUG,
InMobiNetworkValues.LOGLEVEL_ERROR

Log level for InMobi SDK

More Information

Please download the sample code from here.

The latest documentation and code samples for the AdMob SDK are available here.