Integrating and monetizing with InMobi SDK is easy. To begin, download our latest iOS SDK (ver 10.7.8) here or from Cocoapods.
If you are not already using Cocoapods, go to your Xcode project directory and create a pod file using the command below.
pod init
Add the following to Podfile
.
pod 'InMobiSDK'
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
10.5.0, 10.5.1, 10.5.3, and 10.5.4 versions are available only on InMobiSDK-Swift
pod, and the remaining versions are available on InMobiSDK
pod.
Alternatively, you can integrate the framework directly.
1. Add the following MANDATORY frameworks to your Xcode project:
InMobiSDK.xcframework
from the downloaded InMobi iOS SDK bundlelibsqlite3.0.tbd
libz.tbd
WebKit.framework
2. Add -ObjC
flag to the Other Linker Flags:
-ObjC
flag3. Navigate to General tab > Frameworks, Libraries, and Embedded Content. Add InMobiSDK.xcframework
as Embed & Sign.
Let’s pause for some checks before we begin initializing the SDK:
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) - 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.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
Refrain from using InMobi domains and CDN in the exception list as it will result in errors during the runtime.
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.
App.entitlements
file.For location consent, you must inform the user to pass the location data. For more information, see Pass Location Information.
As an attribution solution in the absence of a consistent Identifier for Advertisers (IDFAs), Apple provides the SKAdNetwork API. Using SKAN indicates that your app monetizes with InMobi and accepts bids from SKAN-enabled buyers.
To configure your app with SKAdNetwork IDs, make sure you enter the InMobi SKAdnetwork ID and the IDs of all the buyers to whom you want to sell your inventory to, in your app Info.plist file. Follow these instructions from Apple.
The SKAdNetwork IDs for InMobi and InMobi buyers are hosted together in two formats:
These files are frequently updated.
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;
import InMobiSDK
/**Please do not remove the window property as it can lead to undefined behavior**/
var window: UIWindow?
Initialize the SDK in the didFinishLaunchingWithOptions
method within the app delegate's.m file:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
void (^completionBlock)(NSError*) = ^( NSError* _Nullable error) {
if (error) {
NSLog(@"SDK Initialization Error - %@", error.description);
}
else {
NSLog(@"IM Media SDK successfully initialized");
}
};
[IMSdk setLogLevel:IMSDKLogLevelDebug];
[IMSdk initWithAccountID:kIMAccountID consentDictionary:@{IMCommonConstants.IM_GDPR_CONSENT_AVAILABLE: @"true", IMCommonConstants.IM_GDPR_CONSENT_IAB: @"<<consent in IAB format>>"} andCompletionHandler:completionBlock];
return YES;
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
IMSdk.setLogLevel(IMSDKLogLevel.debug)
IMSdk.initWithAccountID("accountID", consentDictionary: [IMCommonConstants.IM_GDPR_CONSENT_AVAILABLE: "true", IMCommonConstants.IM_GDPR_CONSENT_IAB: "<<consent in IAB format>>" ]) { (error) in
if let error = error {
print(error.localizedDescription)
}
}
return true
}
Before you proceed, it is important to understand GDPR and how it is affecting your traffic in the EEA region.
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 | String | A consent string is a series of numbers, which identifies the consent status of an Adtech Vendor.
The string must follow the IAB contracts as mentioned here. |
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_IAB. |
gdpr | String | Whether or not the request is subjected to GDPR regulations (0 = No, 1 = Yes), omission indicates Unknown. |
A 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. Within a session, a consentObject can be updated as below:
[IMSdk updateGDPRConsent:@{<Insert consentObject dictionary here>}];
IMSdk.updateGDPRConsent(<Insert consentObject dictionary here>)
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.
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: 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];
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
CLLocation *clLocation = locations.lastObject;
[IMSdk setLocation:clLocation];
[self.locationMgr stopUpdatingLocation];
}
"var locationMgr: CLLocationManager?
//Using CLLocationManagerDelegate fetch the coordinate
locationMgr = CLLocationManager()
locationMgr?.requestWhenInUseAuthorization()
locationMgr?.delegate = self
locationMgr?.startUpdatingLocation()
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let clLocation = locations.last {
IMSdk.setLocation(clLocation)
}
locationMgr?.stopUpdatingLocation()
}"
Ensure that you have user consent to share this data. The following values are supported:
Age | Gender |
|
|
Example:
[IMSdk setGender:IMSDKGenderMale];
[IMSdk setAgeGroup:IMSDKAgeGroupBetween25And29];
IMSdk.setGender(.female)
IMSdk.setAgeGroup(.between25And29)
We recommended using age restriction information as well to comply with policies such as the data practices for Google’s Family Apps. You must determine the definition of age restriction depending on the user’s geographic data location. If the value is passed as True, the InMobi SDK will not transmit device identifiers such as (“AAID” in Android & “IDFA” in iOS). Note that the default value will be False.
[IMSdk setIsAgeRestricted: false]; // possible value are true, false
IMSdk. setIsAgeRestricted(false) // possible value are true, false
The InMobi SDK is not required to include data usage and tracking domain details in the privacy manifest file for Apple's Spring 2024 deadline, as it is not categorized among Apple's commonly used SDKs. We're actively monitoring this at InMobi and will update you on any changes.
You must mention your usage of the Reason API in the privacy manifest. Apple has released an update, effective from March 13, which mandates that developers receive a notification email about the missing reasons in the privacy manifest for apps utilizing APIs requiring approved reasons. Starting May 1, you should incorporate the sanctioned reasons for the specified APIs into the application's code.
To align with these requirements, our upcoming release, InMobi SDK 10.6.7, scheduled for March 11, 2024, will include a privacy manifest file delineating the InMobi SDK's Reason API usage. It's noteworthy that XCode will seamlessly detect the reasons API following the update of the InMobi SDK.
API category | API Category Type | Reason | Comments |
---|---|---|---|
Disk space APIs | NSPrivacyAccessedAPICategoryDiskSpace | E174.1 | The SDK optimizes parallel asset downloads and prevents download failures. |
User defaults APIs | NSPrivacyAccessedAPICategoryUserDefaults | CA92.1 | The SDK stores essential operational data, including details like the previous SDK version and app launches. |
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.
InMobi SDK uses iOS WKWebView to render HTML ads. As per Apple design, WKWebView does not respect the AVAudioSessionCategory
set by the application, and also the OMSDK audio measurability remains inoperative. To have control over the HTML video ads, SDK manages the AVAudioSession
.
The ad’s audio may mix in with the app’s audio. Hence, it is recommended to stop the app's audio when you present the fullscreen ads and resume it once the ad is dismissed.
From SDK 9.1.5 onwards, you can find a new API for handling AVAudiosSession
. This feature is enabled by default.
+(void)shouldAutoManageAVAudioSession:(BOOL)value;
If you set it to YES, the SDK manages AVAudioSession
automatically. When the ad is presented, the API sets AVAudioSession's category to AVAudioSessionCategoryAmbient
and categoryOption
to AVAudioSessionCategoryOptionMixWithOthers
for Interstitial video ads. When the ad is dismissed, SDK resets the AVAusioSessionCategory
and categoryOption
to the original states.
This setting does not stop the ad audio from playing in the app. It mixes with the ad’s audio. Hence, it is recommended for you to stop the app’s audio when presenting the fullscreen ads and resume it after the ad is dismissed.
If you set it to NO, the SDK stops managing AVAudioSession
during the HTML video playback lifecycle and OMSDK, audio measurability may remain inoperative causing a revenue loss for the publisher.
For more information, please contact your respective partners.
You are all set now! Let’s now have a look at how you can set up different ad formats and begin monetizing. Ready?
By installing this SDK update, you agree that your Children Privacy Compliance setting remains accurate or that you will update that setting, whenever there is a change in your app's audience. You may update the app's Children Privacy Compliance settings at https://publisher.inmobi.com/my-inventory/app-and-placements.