AdMob (iOS)

Introduction

Integrating and monetizing InMobi SDK with AdMob is easy. Please refer to this guide for integration instructions. You have access to the following ad types from InMobi via AdMob mediation:

  • Banner
  • Interstitial (Static Interstitial and Full-screen Video Ads)
  • Rewarded Interstitial
  • Native

Before you begin setting up InMobi as an ad source on AdMob dashboard, it’s important that you create an InMobi account, register your app, configure placements and complete the payment information. You can learn more about it here.

If you have completed the above steps, then you are all good to begin setting up InMobi as an ad source on AdMob. Let’s begin!

Note

The latest version of InMobi SDK supports iOS 9 or higher. Also, this version of iOS SDK requires XCode 12 or higher.


Configure InMobi as an Ad Source

Logon to your AdMob account and navigate to the specific ad-unit that you want to monetize via the InMobi SDK. Under mediation, navigate to “ad-sources” (if you have integrated solely with AdMob, the number of ad sources will be one).

  1. Select a new ad network and add InMobi as an ad source.

  2. In the Network Settings page for InMobi, insert your InMobi account ID and placement ID.

    Your account ID is available in your InMobi account as illustrated in the screenshot below.

    Your Placement ID is present under the placement section in the InMobi dashboard, as illustrated in the screenshot below.

  3. Setting up Ad network optimization: For automatic eCPM optimization, the publisher must provide his/her InMobi reporting API credentials in the AdMob UI. If you want to find your API credentials, go to Account settings->API Key-> Generate Key. Reach out to InMobi support in case you face any issues.

 

Set up Rewarded Interstitials

You can configure the reward either on AdMob’s dashboard or on InMobi’s dashboard.

To configure the same on InMobi’s dashboard, choose “Use third-party ad network settings”.

Fill in the key-value pair for the reward details, which the InMobi SDK will honour once the user completes watching the video. AdMob will in turn pass this back in the reward callback. For example, you could fill in the following reward details: Key = Coins, Value = 1000

Note

While setting up the rewards on InMobi dashboard, please make sure the reward value is in the form of Integer.

 

Set up Native Ads

When creating a native content placement type on the InMobi dashboard to support a native ad unit on AdMob’s dashboard, ensure you don’t change the key names on the InMobi dashboard. This is to ensure that the InMobi integration works seamlessly on native ad formats.

Remember

  • InMobi Adapter doesn’t honor shouldRequestMultipleImages flag for Native Ads in AdMob SDK.
  • InMobi Adapter also doesn’t honor getImageOrientation/preferredImageOrientation flag in AdMob SDK.

 

Add the SDK and Adapter

Integrating the InMobi SDK and the AdMob Adapter is fairly seamless. To get an ad from InMobi, you need to incorporate both InMobi SDK and the Adapter. But before we begin, let’s pause for some checks:

Important Prerequisites:

Checkpoint 1: Preparing your App for iOS 10

App Transport Security (ATS), a default setting introduced with iOS 9 that mandates apps to make network connections only over TLS version 1.2 and later. Though InMobi is committed towards the adoption of HTTPS, the current setup requires our demand partners to support this change and be 100% compliant with all the requirements of ATS.

While we work with our partners progressing towards a secure environment, to ensure ads work on iOS 9 and later versions, you need to follow these steps as a near-term fix:

Disable ATS (Recommended) - to ensure non-secure content from the partners work correctly in your updated apps. To disable ATS flag, add the following code snippet to your app's Info.plist.

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key> 
    <true/> 
</dict>

Disable ATS with exceptions (Not Recommended) - in case you plan to migrate towards ATS compliance. You can achieve so by allowing secure content from your domains by adding them on the exception list.

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSAllowsArbitraryLoads</key> 
    <true/> 
    <key>NSExceptionDomains</key> 
    <dict> 
        <key>example.com</key> 
        <dict> 
            <key>NSIncludesSubdomains</key> 
            <true/> 
        </dict> 
    </dict> 
</dict>

Remember

Refrain from using InMobi domains and CDN in the exception list as it will result in errors during the runtime.


Checkpoint 2: iOS 12 WiFi Settings

Apple has introduced privacy settings to access WiFi details from iOS 12 onwards. To boost monetization and relevant user experience we encourage sharing WiFi details for targeted advertising.

  1. Enable ‘Access WiFi Information’ on your App ID.

  2. Enable access ‘Access WiFi Information’ for your target app from XCode capabilities.

  3. Ensure WiFi Access is added to your App.entitlements file.

 

Add the InMobi SDK

To add the SDK to your project, please follow Step 1 & 2 from the iOS SDK Integration section here.
 

Add the InMobi Adapter

Download the adapter from here. Add the InMobi adapter bundle to your Xcode project.


Code Steps

The code steps remain the same as they are for regular AdMob integration for fetching and loading an ad. Use the AdMob account ID to initialize the AdMob SDK and AdMob “ad unit id” to request and fetch an ad.

Note

Do not remove window property from the AppDelegate.h file as it may lead to undefined behaviour.


Pass User Consent to InMobi SDK

The publishers monetizing in EEA region will have to pass user consent to InMobi SDK. The publishers can use consent gathering mechanism of their choice (like Consent SDK ), and they will have to pass on this consent information to InMobi. To pass consent information, the publisher has to call: [GADMInMobiConsent updateGDPRConsent:consentObj];

The consentObj will be a JSON object with the following keys:

Key

Type

Inference

gdpr_consent String

A consent string is a series of numbers, which identifies the consent status of an Ad tech Vendor.

The string must follow the IAB contracts as mentioned here.

gdpr_consent_available

boolean

"true": Publisher has provided consent to collect and use user’s data.

"false": Publisher has not provided consent to collect and use user’s data.

Any value other than “true” and “false” is invalid and will be treated as value not provided by publisher, i.e. empty value.

gdpr

String

Whether or not the request is subjected to GDPR regulations, deviation from the set values (0 = No, 1 = Yes ), indicate an unknown entity.


More Information

Please download the sample code from here.

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


Test the Integration

To ensure AdMob SDK relays the ad request to InMobi for testing, you can do the following.

  1. Set manual Ad network optimization for every network including AdMob. Uncheck the “Ad network optimization” checkbox.
  2. Set manual eCPM floors for all networks keeping the eCPM floor for InMobi higher than other networks, this will ensure that the ad request gets relayed to InMobi for testing. In the example below, InMobi floor is set to $5 and AdMob is set to $0.01.

Once you have completed the above steps, you can test and relay the requests to InMobi SDK for ad loads.

 

Enabling Key SDK Logs

Enable debug logs by adding following to didFinishLaunchingWithOptions method within the app delegate's .m file, as shown below:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{     
    //Initialize InMobi SDK with your account ID 
    [IMSdk initWithAccountID:@"Insert InMobi account ID here"]; 
    //Set log level to Debug 
    [IMSdk setLogLevel:kIMSDKLogLevelDebug];  
    // Do your stuff. 
    return YES; 
} 

You can also use the feedback available on the diagnostics tab in the InMobi dashboard (for ad unit and ad request).

Advanced Configurations

Providing Location and Demographics Data

Recommended

If your app collects location from the user, we recommend passing it up, as impressions with location signals have higher revenue potential. InMobi SDK will automatically pass the location signals if available in the app. If you use location in your app but would like to disable passing location signals to InMobi, then select NO under the “Location Permission” section for your property on the InMobi Customer Interface.

Otherwise: Location can be passed using following method under GADInMobiExtras.h.

- (void)setLocation:(CLLocation*)location;

All non-context specific parameters can be passed to InMobi for richer ad targeting. Please ensure that you pass on the values for the fields which you collect, and have user consent to share this data. Class "GADInMobiExtras" provides methods to set demographic information about the user.

InMobi supports the following parameters:

Method Name

Value

Description

setAgeGroup

kIMSDKAgeGroupBelow18

kIMSDKAgeGroupBetween18And24

kIMSDKAgeGroupBetween25And29

kIMSDKAgeGroupBetween30And34

kIMSDKAgeGroupBetween35And44

kIMSDKAgeGroupBetween45And54

kIMSDKAgeGroupBetween55And65

kIMSDKAgeGroupAbove65

The age group of the user

setEducationType

kIMSDKEducationHighSchoolOrLess kIMSDKEducationCollegeOrGraduate kIMSDKEducationPostGraduateOrAbove


 

The education level

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

setAge

Integer

The age of the user

setInterests

Any String

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

setPostalCode

Any String

The postal code (usually a 5 digit number)

setAreaCode

Any String

The area code (part of the telephone number)

setLanguage

Any String

The native language of the user (if known)

setLocationWithCityStateCountry

Any String

Sets location with City, State, Country being passed

setKeywords

Any String

Keywords to be passed in the ad request


Setting up Demographic Params

Here is a sample for setting up the InMobi SDK Demographic params. Publishers are requested to set the values of params as they want:

InMobiSdk.setAreaCode("080");
InMobiSdk.setEducation(Education.HIGH_SCHOOL_OR_LESS);
InMobiSdk.setGender(Gender.MALE);
InMobiSdk.setAge(23);
InMobiSdk.setPostalCode("122009");
InMobiSdk.setLogLevel(LogLevel.DEBUG);
InMobiSdk.setLocationWithCityStateCountry("blore", "kar", "india");
InMobiSdk.setLanguage("ENG");
InMobiSdk.setInterests("dance");
InMobiSdk.setYearOfBirth(1980);
 

Audio Handling in WKWebView

For publishers running any audio or video media as the main content, we recommend listening to interruptions by observing AVAudioSessionInterruptionnotification posted by AVAudioSession. This will help preempt any content interruptions and help address user experience issues upfront. For more information, see these Apple documents: Article 1, Article 2.

Additional Instructions for GDPR

Follow the additional instructions below about GDPR settings on your Google dashboard for higher monetization results. The following configuration applies to traffic from European Economic Area and publishers using AdMob/GAM CMP for GDPR consent purposes. Google CMP provides two ways of adding ad partners on their AdMob/GAM platform:

  • Commonly used ad partners
  • Custom ad partners

InMobi is not part of ‘Commonly used ad partners’ by default, and you must add it manually by selecting Custom ad partners.

Follow the instructions below to enable InMobi under Custom ad partners on your Google dashboard.

  1. On the Google Dashboard, select Privacy & messaging GDPR Settings Review your ad partners.
  2. Select Custom ad partners and then InMobi from the list and save the setting.

On This Page

Last Updated on: 14 Feb, 2023