AdMob | iOS

Getting Started with iOS Integration

Step 1: Creating an InMobi Account

To set up an InMobi account:

  1. Sign up as a publisher.

  2. Complete the e-mail verification for your account.

Step 2: Registering your App

  1. Click Add an App, and then click the link as shown below.
  2. Name your app, and then select your platform and proceed.
  3. Read the condition about properties directed to children below 13 years, and then select the check box if it applies to you.

    Note: For apps without a URL, the test mode is enabled by default. Once live, you can click the link to enter the URL on the dashboard as shown below.
    Your app is ready to monetize.

Step 3: Creating Placement Ids

Placement Ids are InMobi’s terminology for AdMob’s ad-unit ids. For example, if you are trying to monetize a banner ad unit via InMobi network, you need to create a placement id of type “Banner”.

Refer the following table for successful monetization:

AdMob Ad Unit Type InMobi Placement Type
Banner Banner
Interstitial Interstitial
Rewarded Interstitial Rewarded Video
Native Native Content
  1. Select the relevant ad format to define the placement of your ad.

  2. Tag the placement for superior monetization, based on the ad unit’s location and context in the app.

Step 4: Filling out the Payout Information

Create, verify and activate your payment profile to make your earning tangible. InMobi follows a payout cycle of 60 days. This means that your earnings for a given month will be credited to you at the end of the 60-day payout cycle. You have the option of receiving your payouts via PayPal or wire transfer/RTGS.

For more information about payment terms, see here.

Step 5: Configuring InMobi as an Ad Source on AdMob’s Dashboard

  1. Log on to your AdMob account.
  2. Navigate to the specific ad-unit that you want to monetize via the InMobi SDK.
  3. Under mediation navigate to ad-sources (if you have integrated solely with AdMob, number of ad sources will be one). Select new ad network, and then add InMobi as ad source.

  4. 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.

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

  5. Setting up Ad network optimization: For automatic eCPM optimization, the publisher must provide his/her InMobi reporting API credentials in the AdMob UI.
    Reach out to InMobi support to generate the secret key required for this feature.

Setting 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

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

Setting up Native Ads

Ensure not to change key names on InMobi dashboard when creating a native content placement type on the InMobi dashboard to support a native ad unit on AdMob’s dashboard. This is to ensure that the InMobi integration works seamlessly on native ad formats.

Notes:

  • 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.

Step 6: Integrating InMobi SDK via AdMob 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.

Targeting your App for iOS 9+

A key feature in iOS 9, 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 serve 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 works 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>
    			

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

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.

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

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

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

Adding the InMobi SDK and Adapter to Your Project

Adding the SDK to your Project

Method 1: Integration via Cocoapods (https://cocoapods.org/pods/InMobiSDK)

Follow these steps :

  1. Go to your Xcode project directory and create a pod file using the command below.
    pod init
    			
  2. Add the following to Podfile.
    pod 'inmobi-ios-sdk', :git => 'https://bitbucket.org/aerservllc/inmobi-ios-sdk-pod.git'
    			
  3. Run the command below to complete the task for dependency.
     pod install
    			

    Workspace with pods is created.

Method 2: Integrating the framework directly

Add the following MANDATORY frameworks to your Xcode project:

  • InMobiSDK.framework from the downloaded InMobi iOS SDK bundle
  • libsqlite3.0.tbd
  • libz.tbd
  • WebKit.framework

Add -ObjC flag to the Other Linker Flags:

  1. Open your project in Xcode.
  2. Select Application Target > Build Settings.
  3. In the Search box, search for Other Linker Flags.
  4. Add the -ObjC flag

Adding the InMobi Adapter to Your Project

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.

Passing user consent information 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:

 [InMobiConsent updateGDPRConsent:consentObj];
		

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

Key Type Inference
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.

Note: 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 true and false, indicate an unknown entity.

More Information

You can download the sample code from here.

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

Step 7: Testing the Integration

To ensure AdMob SDK relays the ad request to InMobi for testing:

  • Set manual Ad network optimization for every network including AdMob.
  • 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.

After performing the steps above, you can test and relay the requests to InMobi SDK for ad loads.

Enabling Key SDK Logs

Enable debug logs by adding the 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 leverage feedback available on the diagnostics tab on the ad unit and ad request.


Step 8: Advanced

Providing Location and Demographics Data

Passing Location Signals

Recommended: 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: You will have to 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 Value Description

setAgeGroup

AgeGroupBelow18

AgeGroupBetween18And24

AgeGroupBetween25And29

AgeGroupBetween30And34

AgeGroupBetween35And44

AgeGroupBetween45And54

AgeGroupBetween55And65

AgeGroupAbove65

The age group of the user

setEducationType

EducationHighSchoolOrLess

EducationCollegeOrGraduate

EducationPostGraduateOrAbove

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 five-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

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 read these Apple documents: Article 1, Article 2.

Note: In case you want to write your own custom event class to integrate InMobi via MoPub please see here.

Sample for setting up the InMobi SDK Demographic params. Publisher need 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);