MoPub (iOS)


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

  • Banner
  • Medium - Banner
  • Fullscreen (Interstitial, Full-screen Video Ads)
  • Rewarded Video
  • Native

Before you begin setting up InMobi as an ad source on MoPub 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 MoPub. Let’s begin!


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

Configure InMobi as an Ad Source

Log on to your MoPub account and identify the ad units that you wish to monetize via InMobi. Then, navigate to the Networks tab.

  1. To monetize via InMobi, select Custom SDK Network. It allows you to integrate InMobi via MoPub with plug-n-play "Custom Events".


    You need both the InMobi SDK and the custom event for successful integration.

  2. Navigate to the specific ad unit that you want to monetize via InMobi.

  3. Enter the name of InMobi custom event class specific for that particular ad format as Custom Event Class value. For example, Interstitial Ad - the custom event is called: “\InMobiInterstitialCustomEvent”.

    Use Custom Event class names. Here is the complete grid for custom events by ad unit type:

    Ad Unit

    Class Name



    Medium (300x250 banner)




    Rewarded Video




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

  5. Placement ID is present under the placements section as illustrated in the screenshot below.

  6. Enter the Account ID and the Placement ID in the following format in the placeholder for Custom Event Class Data.

    {"placementid":"<Enter your InMobi Placement ID here>","accountid":"<Enter your InMobi Account ID here>"}

    A sample input will look like this:


Add the SDK and Adapter

Integrating the InMobi SDK and the custom event to your project is fairly seamless. 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.



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.



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

App Store Review

If ATS is not disabled for apps, monetization will be impacted on devices running iOS 9+. The demand ecosystem has yet to migrate to SSL enabled world, causing ads not to render. The ATS disablement will trigger additional App Store review for your app, and requires you to provide justification. A sample of justification for consideration:

For monetization must support serving ads from the advertisers that do not support secure connections.

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 Custom Event

Option 1: Integration via Cocoapods

  1. Add the following to Podfile.

    pod 'InMobiMoPubPlugin'

    If you are working with MoPub SDK below v5.14.1 or lower, please use InMobiMoPubPlugin v9.1.0.0. To use this version, add the following to Podfile instead

    pod 'InMobiMoPubPlugin', '='
  2. Once you have added it to the pod file, run the command below to complete the task for dependency. You now have a workspace with the pods.

    pod update  

Option 2: Integrating the framework directly

Alternatively, you can integrate the framework directly.

  • Download the latest InMobiMoPubPlugin (5.14.1) from here.
  • Alternatively to support MoPub SDK v5.14.1 and below, please download the compatible adapter from here.

Code Steps

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

Pass User Consent to InMobi SDK

The publishers monetizing in EEA+UK+Switzerland region will have to pass user consent to InMobi SDK. The publishers can use consent gathering mechanism of their choice, and they will have to pass on this consent information to InMobi.

consentObject - A consentObject is a dictionary representation of all kinds of consent provided by the publisher to the SDK. The key is mandatory if you wish to monetize traffic from EEA region. You can read further on GDPR regulations here.

  • Copy the InMobiGDPR.h header from InMobiAdapter folder, into your project.
  • Use [InmobiGDPR setGDPRConsentDictionary] API to pass on the consentObject. Publisher will have to grant or revoke consent based on the consent provided by the user. It should be called once every session. In case the API is not called, we will presume that consent is not available for users belonging to EEA+UK+Switzerland region.
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 String

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 subject to GDPR regulations - 0 =No, 1 = Yes - omission indicates Unknown.

The keys can be accessed via the following string constants in the Adapter:

  2. gdpr_consent_available - IM_MPADAPTER_GDPR_CONSENT_AVAILABLE

More Information

You can see the complete sample code and example here.

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

Test the Integration

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

  1. Set manual Ad network optimization for every network including MoPub.
  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. For example for InMobi set the floor to $5 while MoPub marketplace is set to $0.05.


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 {     
    [IMSdk setLogLevel:kIMSDKLogLevelDebug];  
    //Initialize InMobi SDK with your account ID 
    [IMSdk initWithAccountID:@"Insert InMobi account ID here"]; 
    //Set log level to Debug 
    // 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


If your app collects location from the user, we recommend passing it up, as impressions with location signal 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 TURN OFF the “Location Automation” for your property on the InMobi dashboard.

Otherwise, modify the Custom Event class for your ad-unit to pass on the data using the InMobi SDK API. Please see sample code for more details.

InMobi supports the following parameters:

Method Name












The age group of the user


CLLocation object


Setting up Demographic Parameters

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

[IMSDK setAgeGroup:kIMSDKAgeGroupBetween18And24];
[IMSdk setGender:kIMSDKGenderMale];

Audio Handling in WKWebView

AVAudioSession. This will help preempt any content interruptions and help address user experience issues upfront. For more information read these Apple documents: Article 1, Article 2.

Was this page helpful?

On This Page