iOS Guidelines |

Getting Started with iOS Integration

Integrating and monetizing with InMobi SDK with is easy. This iOS SDK integration guide will help you with the following:

To begin, download our latest iOS SDK (ver 900+) here or from Cocoapods.

1. The latest version of InMobi SDK supports iOS 9 and later. Also, this version of iOS SDK requires XCode 11 and later.
2. We recommend to call all InMobi apis on main thread.
3. If you are interested in using our SDK for Google Open Bidding, then kindly use the older version of our SDK (740) that is available for download here.

Important note on UIWebView:
While InMobi SDK has removed support for UIWebView, the SDK still has reference to it through our viewability partner, MOAT.
All traces of UIWebView will be completely removed in our next upgrade.

Step 1: Adding the SDK to your Project

Option 1: Integration via Cocoapods

  1. If you are not already using Cocoapods, go to your Xcode project directory and create a pod file using the command below.
    pod init
  2. Add the following to Podfile.
    pod 'InMobiSDK'
  3. If you want to integrate using Google Open Auction
    pod 'InMobiSDK', '~> 7.4.0'
  4. 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.

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

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

Important Prerequisites:

Let’s pause for some checks before we begin initializing the SDK:

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) - if 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.

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.

Note:Please ask the user for location consent. Here is how how to do that.

Step 2: Initializing the SDK

Step 2.1 Import the InMobi SDK header in your AppDelegate.h file:

@import InMobiSDK;
/**Please do not remove the window property as it can lead to undefined behavior**/
 @property (strong, nonatomic) UIWindow *window;

Step 2.2 Initialize the SDK in the didFinishLaunchingWithOptions method within the app delegate's .m file:

- (BOOL)application:(UIApplication *)application  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
//Initialize InMobi SDK with your account ID

NSMutableDictionary *consentdict = [[NSMutableDictionary alloc] init];
//Consent Value needs to be collected from end user
[consentdict setObject:@"true" forKey:IM_GDPR_CONSENT_AVAILABLE];
[consentdict setObject:@"1" forKey:@"gdpr"];
[IMSdk setLogLevel:kIMSDKLogLevelDebug];

[IMSdk initWithAccountID:INMOBI_ACCOUNT_ID consentDictionary:consentdict]];
// Do your stuff.
return YES;

Let’s understand a few things here before you proceed:

What is a 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.

Key Type Inference
gdpr_consent_available String "true" : User has provided consent to collect and use data.

"false": User has not provided consent to collect and use data.

Any value other than “true” and “false” is invalid and will be treated as value not provided by user.

The key, gdpr_consent_available can be accessed via string constant IM_GDPR_CONSENT_AVAILABLE.

gdpr String Whether or not the request is subjected to GDPR regulations (0 = No, 1 = Yes), omission indicates Unknown.

Important note on consentObject:

  1. consentObject has to be provided in every session. SDK does not persist consent, it only keeps the consentObject in memory. If the app is relaunched, SDK will lose the consentObject.
  2. Within a session, consentObject can be updated as below:
    [IMSdk updateGDPRConsent:@{<Insert consentObject dictionary here>}];
  3. As part of the General Data Protection Regulation (“GDPR”) publishers who collect data on their apps, are required to have a legal basis for collecting and processing the personal data of users in the European Economic Area (“EEA”). Please ensure that you obtain appropriate consent from the user before making ad requests to InMobi for Europe and indicate the same by following our recommended SDK implementation. Please do not pass any demographics information of a user; if you do not have user consent from such user in Europe.

Note: You can locate your account ID from the account interface as shown in the image below:

Step 2.3 | Pass the location information to allow better ad targeting

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 can set NSLocationWhenInUseUsageDescription flag (description for asking location permission) in your info.plist file.

//Using <CoreLocation/CoreLocation.h> fetch the coordinate
      	self.locationMgr = [[CLLocationManager alloc] init];
    	[self.locationMgr requestWhenInUseAuthorization];
      	self.locationMgr.desiredAccuracy = kCLLocationAccuracyHundredMeters;
      	self.locationMgr.delegate = self;
    	[self.locationMgr startUpdatingLocation];

#prgma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
 CLLocation *clLocation = locations.lastObject;
       [IMSdk setLocation:clLocation];
[self.locationMgr stopUpdatingLocation];

Step 2.4 Pass age and gender information to allow better ad targeting. Ensure that you have user consent to share this data. The following values are supported:

Age Gender
  • kIMSDKAgeGroupBelow18
  • kIMSDKAgeGroupBelow18And24
  • kIMSDKAgeGroupBetween25And29
  • kIMSDKAgeGroupBetween30And34
  • kIMSDKAgeGroupBetween35And44
  • kIMSDKAgeGroupBetween45And54
  • kIMSDKAgeGroupBetween55And65
  • kIMSDKAgeGroupAbove65
  • kIMSDKGenderMale
  • kIMSDKGenderFemale


[IMSdk setGender:kIMSDKGenderFemale];
[IMSdk setAgeGroup:kIMSDKAgeGroupBetween25And29];


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.

You are all set now! Let’s now have a look at how you can set up different ad formats and begin monetizing. Ready?