What is the InMobi iOS SDK?
The InMobi iOS SDK allows you to monetize your iOS app with a wide range of ad formats. From banner ads to full-screen native interstitial ads, video ads, and native content ads, to our newly introduced rewarded video and playable ads, you can deliver ads from the InMobi Network in any shape and form for a better user experience. All with one unified SDK.
Note: The InMobi iOS SDK 5.1 has been designed to support iOS 7 and above only.
Also, this version of the InMobi SDK requires XCode 7.0 and above.
Important:
InMobi strongly recommends that users still on InMobi SDK 4.5, and below, upgrade to SDK 5.0 immediately as it contains substantial performance and stability improvements.
To get started with the integration, complete the following steps:
Copy the following header files and binary from the downloaded SDK bundle to your project.
libInMobi-5.x.x.a
IMSdk.h
IMBanner.h
IMBannerDelegate.h
IMInterstitial.h
IMInterstitialDelegate.h
IMNative.h
IMNativeDelegate.h
IMCustomNative.h
IMRequestStatus.h
IMCommonConstants.h
Add the following frameworks to your Xcode project:
AdSupport.framework
AudioToolbox.framework
AVFoundation.framework
CoreLocation.framework
CoreTelephony.framework
CoreGraphics.framework
EventKit.framework
EventKitUI.framework
Foundation.framework
MediaPlayer.framework
MessageUI.framework
Security.framework
Social.framework
StoreKit.framework
SystemConfiguration.framework
UIKit.framework
SafariServices.framework
libsqlite3.0.tbd
libc++.tbd
libz.tbd
Note: Set NSLocationWhenInUseUsageDescription
flag to YES in your info.plist file.
Note:
Add the
-ObjC
flag to the Other Linker Flags to load all the classes when using Categories. To do so, complete the following steps:
A key feature in iOS9, Application Transport Security (ATS) is a new default setting that mandates apps to make network connections only over TLS ver. 1.2 and above. 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 above devices, we would need you to follow these steps as a near-term fix:
Import the
"InMobi.h"
and "
IMCommonConstants.h"
in the AppDelegate header file, as shown below:
#import "IMSdk.h"#import "IMCommonConstants.h"
In the first step to integrate with InMobi, you need to initialize the InMobi SDK. The InMobi SDK requires your InMobi Account ID (Publisher ID) for initialization. Use this ID while integrating the InMobi SDK. It is mandatory to initialize the SDK during app launch. Your account ID is available in your InMobi account as illustrated in the screenshot below:
Initialize the SDK in the
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"]; // Do your stuff. return YES; }
Banner ads are the most common ad format. They consist of an image with a hypertext link that takes the user to the website. These ads display either statically on the page, or sometimes with an incorporated animation. Banners are small ads that, when clicked, typically take the user to some form of a full screen, in-app browsing experience.
To add a banner to your application create an instance of
IMBanner
and implement IMBannerDelegate
. The IMBanner
class takes care of fetching an ad and passing it to the application, while IMBannerDelegate
gives ad status callbacks.
iOS apps are composed of
UIView
objects, Objective-C instances seen by the user as text areas, buttons, and other controls. The IMBanner
is simply a UIView
subclass displaying small HTML5 ads that respond to user touch. It is easy to create IMBanner
in code.
To get a banner ad, complete the following steps:
The InMobi SDK provides two mechanisms to implement a banner ad:
Both the above methods result in the same outcome - a banner ad displayed within your app. The two methods are detailed below:
To display a banner ad, you will need a banner placement ID. To create a new placement ID, please refer to the Getting Started section of this document. If you have already created a placement, please follow the steps outlined here to obtain the placement ID.
Initialize the banner with the placement ID. And complete the below steps:
IMBanner.h
and IMBannerDelegate.h
files. Then, declare a banner instance in the header file. Your header file should look like:
#import <UIKit/UIKit.h> #import “IMBanner.h” #import “IMBannerDelegate.h” #import “IMRequestStatus.h”@interface ViewController : UIViewController <IMBannerDelegate> @property (nonatomic, strong) IMBanner *banner; @end
IMBanner
in your ViewController
. We recommend you to do this is viewDidLoad
method of your ViewController
:
-(void)viewDidLoad { self.banner = [[IMBanner alloc] initWithFrame:CGRectMake(0, 0, 320, 50) placementId:<Insert InMobi placement ID here>]; }
IMBanner
as your view controller before loading the ad. This is so that you will be notified about success or failure. self.banner.delegate = self;
adview
to the main view before loading the ad.[self.view addSubview:self.banner];
[self.banner load];
viewcontroller
class should look like:- (void)viewDidLoad { [super viewDidLoad]; self.banner = [[IMBanner alloc] initWithFrame:CGRectMake(0, 0, 320, 50) placementId:@"Insert your placement ID here" self.banner.delegate = self; [self.view addSubview:self.banner]; [self.banner loadBanner]; }
nil
in the dealloc
method of your UIViewController
, or at any time when you are releasing the banner.
-(void)dealloc { self.banner.delegate = nil; }
IMBannerDelegate.h
for the list of available callbacks. The user can perform necessary action on receiving callback./*Indicates that the banner has received an ad. */ - (void)bannerDidFinishLoading:(IMBanner *)banner { NSLog(@"bannerDidFinishLoading"); } /* Indicates that the banner has failed to receive an ad */ - (void)banner:(IMBanner *)banner didFailToLoadWithError:(IMRequestStatus *)error { NSLog(@"banner failed to load ad"); NSLog(@"Error : %@", error.description); } /* Indicates that the banner is going to present a screen. */ - (void)bannerWillPresentScreen:(IMBanner *)banner { NSLog(@"bannerWillPresentScreen"); } /* Indicates that the banner has presented a screen. */ - (void)bannerDidPresentScreen:(IMBanner *)banner { NSLog(@"bannerDidPresentScreen"); } /* Indicates that the banner is going to dismiss the presented screen. */ - (void)bannerWillDismissScreen:(IMBanner *)banner { NSLog(@"bannerWillDismissScreen"); } /* Indicates that the banner has dismissed a screen. */ - (void)bannerDidDismissScreen:(IMBanner *)banner { NSLog(@"bannerDidDismissScreen"); } /* Indicates that the user will leave the app. */ - (void)userWillLeaveApplicationFromBanner:(IMBanner *)banner { NSLog(@"userWillLeaveApplicationFromBanner"); } /* banner:didInteractWithParams: Indicates that the interstitial was interacted with. */ -(void)banner:(IMBanner *)banner didInteractWithParams:(NSDictionary *)params{ NSLog(@"bannerdidInteractWithParams"); }
You can also add an IMBanner to your
UIViewController
using the Storyboard
by completing the following steps:
UIView
in your ViewController’s view at the position where the ad must be displayed.UIView
to IMBanner
.ViewController.h
file, declare an IBOutlet instance of IMBanner.
Set your property in test mode as described here.
After you create an
IMBanner
and set a refresh interval, the ad will refresh automatically. The default refresh interval set is 60 seconds.
To switch off the auto refresh feature, use the method shown below before loading the ad.
[self.banner shouldAutoRefresh:NO];
To set a custom refresh interval, set the same property:
[self.banner setRefreshInterval:90];
To manually load a new ad, use the below method:
[self.banner load];
NSArray *arrKeys = [[NSArray alloc] initWithObjects:@"tp",nil]; NSArray *arrValues = [[NSArray alloc] initWithObjects:@"admob", nil]; NSDictionary *dict = [[NSDictionary alloc] initWithObjects: arrValues forKeys:arrKeys]; self.banner.extras = dict; self.banner.keywords = @”news";
self.bannerView.transitionAnimation = UIViewAnimationTransitionCurlUp;
Interstitial ads are full screen ads (either static image or video) that are modal in nature. They appear to users either before the launch of an application or at transition points, such as between game levels, or between the homepage and a unique content page. The richer nature of these ads makes them more expensive and subject to impression constraints.
InMobi serves both landscape and portrait type of interstitial ads. The InMobi SDK will automatically ensure that it serves appropriate ads as per the application orientation.
Note:
While configuring the SDK, you have already initialized the InMobi SDK with the appropriate account ID. For interstitial integration use the placement id configured for interstitial ads. If you have missed this configuration step, InMobi will fail to load the interstitial ad.
Interstitial Interface To add an Interstitital to your application create an instance of
IMInterstitial
and implement IMInterstitialDelegate
. The IMInterstitial
class takes care of fetching an ad and passing it to user, while IMInterstitialDelegate
gives ad status callbacks.
The configuration steps for interstitial ads are similar to those for banner ads. To get an interstitial ad, perform the following steps:
IMInterstitial.h
and IMInterstitialDelegate.h
. Declare an interstitial instance in the header file. Your header file should look like this:
#import <UIKit/UIKit.h> #import "IMInterstitial.h" #import "IMInterstitialDelegate.h" #import "IMRequestStatus.h" @interface ViewController : UIViewController <IMInterstitialDelegate> @property (nonatomic, strong) IMInterstitial *adInterstitial; @end
self.adInterstitial = [[IMInterstitial alloc] initWithPlacementId:<Insert your placement ID here>];
interstitial
instance, set the delegate property of IMInterstitial
as your view controller before loading the ad. This is so that you will be notified about the ad receiving success or failure. self.adInterstitial.delegate = self;
[self.adInterstitial load];
Your
viewcontroller
class should look like the following:
- (void)viewDidLoad { [super viewDidLoad]; self.adInterstitial = [[IMInterstitial alloc] initWithPlacementId:@"Insert your placement ID here"]; self.adInterstitial.delegate = self; [self.adInterstitial load]; }
The minimum time between two successive loads must be at least 20 seconds.
interstitialDidFinishLoading: callback
.
if ([self.adInterstitial isReady]) { [self.adInterstitial showFromViewController:self]; }
nil
in the dealloc
method, or at any other time when you are releasing the interstitial.
- (void)dealloc { self.adInterstitial.delegate = nil; }
IMInterstitialDelegate.h
for the list of available callbacks. The user can perform necessary actions on callbacks relieved. These are the list of callbacks:
/*Indicates that the interstitial has received an ad. */ - (void)interstitialDidFinishLoading:(IMInterstitial *)interstitial { NSLog(@"interstitialDidFinishLoading"); } /* Indicates that the interstitial has failed to receive an ad */ - (void)interstitial:(IMInterstitial *)interstitial didFailToLoadWithError:(IMRequestStatus *)error { NSLog(@"Interstitial failed to load ad"); NSLog(@"Error : %@",error.description); } /* Indicates that the interstitial has failed to present itself. */ - (void)interstitial:(IMInterstitial *)interstitial didFailToPresentWithError:(IMRequestStatus *)error { NSLog(@"Interstitial didFailToPresentWithError"); NSLog(@"Error : %@",error.description); } /* indicates that the interstitial is going to present itself. */ - (void)interstitialWillPresent:(IMInterstitial *)interstitial { NSLog(@"interstitialWillPresent"); } /* Indicates that the interstitial has presented itself */ - (void)interstitialDidPresent:(IMInterstitial *)interstitial { NSLog(@"interstitialDidPresent"); } /* Indicates that the interstitial is going to dismiss itself. */ - (void)interstitialWillDismiss:(IMInterstitial *)interstitial { NSLog(@"interstitialWillDismiss"); } /* Indicates that the interstitial has dismissed itself. */ - (void)interstitialDidDismiss:(IMInterstitial *)interstitial { NSLog(@"interstitialDidDismiss"); } /* Indicates that the user will leave the app. */ - (void)userWillLeaveApplicationFromInterstitial:(IMInterstitial *)interstitial { NSLog(@"userWillLeaveApplicationFromInterstitial"); } /* Indicates that a reward action is completed */ - (void)interstitial:(IMInterstitial *)interstitial rewardActionCompletedWithRewards:(NSDictionary *)rewards { NSLog(@"IncentActionCompleted Publisher Callback successfully received"); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"incentivisedAd - params" message:[NSString stringWithFormat:@"%@",rewards] delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil]; [alert show]; } /* interstitial:didInteractWithParams: Indicates that the interstitial was interacted with. */ - (void)interstitial:(IMInterstitial *)interstitial didInteractWithParams:(NSDictionary *)params { NSLog(@"InterstitialDidInteractWithParams"); }
Notes:
showFromViewController
. Otherwise, the error callback interstitial:didFailToPresentScreenWithError:
will be given. For a better user experience, keep listening to the interstitial states so that you can show ads to the user only when interstitial has been loaded completely.showFromViewController:
Set your property in test mode as described here.
InMobi video ads are designed to work on properties that have been set up to show interstitial ads. By default, video ads are enabled on all interstitial-integrated properties. However, if you want you property to display video ads exclusively, please change the ad controls of your interstitial placement and choose the option - Video Ads only.
To configure a video ad, follow the same steps as for interstitial ads.
Reward ads are full screen ads that provide a reward to the user upon the completion of a certain action. The reward is provided by the publisher after the user completes the action on the ad. The actions currently supported are Watching a Video.
Reward ads are great because of the following reasons:
If you want to provide a reward to the user for watching a video, please see here for integration. Rewarded ads don’t require any additional integration steps. To be notified about the status of the reward ad, implement the
interstitial:rewardActionCompletedWithRewards:
method of IMInterstitialDelegate
.
- (void)interstitial:(IMInterstitial *)interstitial rewardActionCompletedWithRewards:(NSDictionary *)rewards { NSLog(@"IncentActionCompleted Publisher Callback successfully received"); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"incentivisedAd - params" message:[NSString stringWithFormat:@"%@",rewards] delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil]; [alert show]; }
This is called when the user has completed the action for which he should be rewarded. For example, if the incentive should be awarded when the user watches a video, the delegate will be called when the user has finished watching the video. The rewards are a set of parameters decided by the publisher, for this particular placement ID, to be sent when the user completes the required action to be rewarded.
Important:
Make video ad requests well before when the ad needs to be displayed. This is to cache the ad, providing a smooth and uninterrupted user experience. For example, if you want to show the rewarded video ad at the end of a level (in a gaming app), request for the ad when the level begins.
Native ads are ads that are rendered by the publisher, allowing publishers to give their users a unique experience. A native ad consists of ad assets in a publisher-specified format. Common assets include the image URL associated with the ad, icon URLs of the ad, if any, and texts like title, subtitle, and description.
For creating specific templates for your app layout, please see our help article.
Follow the below steps to implement a Native Content Ad:
To add a native ad to your application create an instance of
IMNative
and implement IMNativeDelegate
.
To get native ads, perform the following steps:
IMNative.h
and IMNativeDelegate.h
files. Declare an instance of class IMNative in your UIViewController
header file. Your header file should look like this:
#import <UIKit/UIKit.h> #import "IMNativeDelegate.h" #import "IMNative.h" #import "IMRequestStatus.h" @interface ViewController : UIViewController <IMNativeDelegate> @property (nonatomic, strong) IMNative* nativeAd; @property (nonatomic, strong) NSString* nativeContent; @end
self.nativeAd = [[IMNative alloc] initWithPlacementId:<Insert native Placement ID Here>];
adview
instance, set the delegate property of IMNative as your UIViewController before loading the ad. This is so that you will be notified about the ad receiving success or failure.
self.nativeAd.delegate = self;
[self.nativeAd load];
Now, the
viewcontroller
class should look like this:
- (void)viewDidLoad { [super viewDidLoad]; self.nativeAd = [[IMNative alloc] initWithPlacementId:@"Insert native Placement ID Here"]; self.nativeAd.delegate = self; [self.nativeAd load]; }
IMNativeDelegate
methods in your ViewController
. IMNativeDelegate provides seven methods that require implementation. All methods will be called on the main thread.
/*The native ad notifies its delegate that it is ready.Fetching publisher-specific ad asset content from native.adContent. The publisher will specify the format. If the publisher does not provide a format, no ad will be loaded.*/ -(void)nativeDidFinishLoading:(IMNative*)native{ NSLog(@"Native Ad loaded %@", native.adContent); } /*The native ad notifies its delegate that an error has been encountered while trying to load the ad.Check IMRequestStatus.h for all possible errors.Try loading the ad again, later.*/ -(void)native:(IMNative*)native didFailToLoadWithError:(IMRequestStatus*)error{ NSLog(@"Native Ad load Failed"); } /* Indicates that the native ad is going to present a screen. */ -(void)nativeWillPresentScreen:(IMNative*)native{ NSLog(@"Native Ad will present screen"); } /* Indicates that the native ad has presented a screen. */ -(void)nativeDidPresentScreen:(IMNative*)native{ NSLog(@"Native Ad did present screen"); } /* Indicates that the native ad is going to dismiss the presented screen. */ -(void)nativeWillDismissScreen:(IMNative*)native{ NSLog(@"Native Ad will dismiss screen"); } /* Indicates that the native ad has dismissed the presented screen. */ -(void)nativeDidDismissScreen:(IMNative*)native{ NSLog(@"Native Ad did dismiss screen"); } /* Indicates that the user will leave the app. */ -(void)userWillLeaveApplicationFromNative:(IMNative*)native{ NSLog(@"User leave"); }
Please refer to
IMNativeDelegate.h
for a list of available callbacks.
nativeAdDidFinishLoading
, . The self.nativeAd.adContent
object provides native ad content and it can be displayed in any new or existing UIView. The native ad content has a set of assets depending on the format you have chosen on the publisher UI.For example, for a news view flow, content will have assets as below:
These assets can be used in various components of your view, as shown below:
if (self.adContent!=nil) { NSData* data = [self.adContent dataUsingEncoding:NSUTF8StringEncoding]; NSError* error = nil; NSDictionary* jsonDict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; NSMutableDictionary* nativeJsonDict = [NSMutableDictionary dictionaryWithDictionary:jsonDict]; /*The above lines of code convert the native JSON content to NSDictionary.*/ if (error == nil && nativeJsonDict != nil) { // The native JSON is parsed and can be used. [nativeJsonDict setValue:[NSNumber numberWithBool:YES] forKey:@"isAd"]; // To differentiate the native JSON dictionary from other data. /* Examples of fetching the image and title are listed below*/ /*Fetch the image url from the dictionary in the following way.*/ NSDictionary* imageDict = [nativeJsonDict valueForKey:@"icon"]; NSString* url = [imageDict valueForKey:@"url"]; /*Fetch the tile from the dictionary*/ NSString* title = [imageDict valueForKey:@"title"]; } }
Create the required views using these values. For example if you are making a table view, and the ad is a cell in the table view then render the views in the tableview’s
tableView:cellForRowAtIndexPath:
method. An example is shown below:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString* cellIdentifier = @"someIdentifier"; UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell==nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier]; } // If this is the row where the ad should be displayed, if([dict valueForKey:@"isAd"]) { UILabel* titleLabel = [[UILabel alloc] initWithFrame:<FRAME_FOR_YOUR_LABEL>]; title.text = title; //This title is from the native JSON dictionary UIImage* image = [UIImage imageWithData:<DATA_FROM_THE_IMAGE_URL>]; UIImageView* imageView = [[UIImageView alloc] initWithFrame:<FRAME_FOR_YOUR_IMAGE>]; imageView.image = image; //Add subviews to the cell [cell addSubView:titleLabel]; [cell addSubView:imageView]; //Bind the cell to the native ad as it has rendered the ad. [IMNative bindNative:self.nativeView toView:cell]; } else { // This is a content item // UnBind the cell as it might be a reused cell from a native ad. [IMNative unBindView:cell]; }
This is just an example on how to access native ad content and render it for a news flow. Content assets may vary for other flows, depending on the view you chose. Please look through your content structure first, and accordingly use the assets for your view flow.
When the ad content is rendered, report this by calling the
bindNative:(IMNative*)native toView:(UIView*)
method on the IMNative
class
[IMNative bindNative:nativeAd toView:renderedUIViewInstance];
Here,
'renderedUIViewInstance'
is the view that is the rendered native ad. That is, for table view, if you are rendering native ad in one of the cells, you must pass the cell to this method once you render the ad. Call unBindView:(UIView*)view
method IMNative
class method when this cell is being reused by other content or other native ad instances.
Both methods will fail if the ad is not yet loaded.
7. Tracking Clicks and The Landing Page
When the view that was rendered from the content of the ad gets clicked, report this click to the native ad instance by calling the
reportAdClick:(NSDictionary*)
params. This gives the publisher a convenient way to report gestures that are considered clicks. The params dictionary can contain any additional information that the publisher wants to provide to the native instance.
To report a click and handle opening of landing page on your own, call ;
[nativeAd reportAdClick:paramsDictionary];
If the native ad content returns the publisher content with a landing page field, you must handle the landing page of the native ad after calling
reportAdClick
method.
The landing page will be present with the key 'landingURL' in the native ad content. Also, the landing page URL will be opened externally. These are default keys generated by the system. You can customize the key names (by logging into your InMobi account) as per your requirements.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary* dict = [self.items objectAtIndex:[indexPath row]]; url = [dict valueForKey:@"link"]; if ([dict valueForKey:@"isAd"]) { NSString* landingUrl = [dict valueForKey:@"landingURL"]; [self.native reportAdClick:nil]; if (landingUrl != nil){ NSURL* landingPageURL = [NSURL URLWithString:landingUrl]; [[UIApplication sharedApplication] openURL:landingPageURL]; } [tableView deselectRowAtIndexPath:indexPath animated:YES]; } To report a click and allow InMobi to open the landing page, call ;[nativeAd reportAdClickAndOpenLandingURL:paramsDictionary]; -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary* dict = [self.items objectAtIndex:[indexPath row]]; if ([dict valueForKey:@"isAd"]) { [self.native reportAdClickAndOpenLandingURL:nil]; } [tableView deselectRowAtIndexPath:indexPath animated:YES]; }
8. Tracking Custom Impressions and Clicks
To report a custom impression tracker or click use the
IMCustomNative
class.
#import “IMCust
To track impressions using custom impression tracker script use the following method. Pass the renderedUIViewInstance and a custom tracker script as parameters.
+(void)bindNative:toView:withImpressionTrackerScript:
To track impressions using custom impression tracker url use the following method. Pass the renderedUIViewInstance and a custom tracker url as parameters.
+(void)bindNative:toView:withImpressionTrackerURL:
Handle opening of landing page on your own as described in the section above
-(void)reportAdClick: withCustomClickTrackerScript:
reportAdClick: withCustomClickTrackerURL:
If you do not want to handle opening of the landing page use the methods below. InMobi will open the landing page for you.
-(void)reportAdClickAndOpenLandingURL:(NSDictionary*)extras withCustomClickTrackerScript:
-(void)reportAdClickAndOpenLandingURL:(NSDictionary*)extras withCustomClickTrackerURL:
The viewcontroller class should look like this:
- (void)viewDidLoad { [super viewDidLoad]; self.nativeAd = [[IMCustomNative alloc] initWithPlacementId:@"Insert native Placement ID Here"]; self.nativeAd.delegate = self; [self.nativeAd load]; } //Track impressions using custom script [IMCustomNative bindNative:self.nativeAd toView:UIRenderedView withImpressionTrackerScript:@"custom script here"]; //Track impressions using custom URL [IMCustomNative bindNative:self.nativeAd toView:UIRenderedView withImpressionTrackerURL:"custom impression tracking URL here"] //Track clicks using custom script. (Note: Landing page needs to be opened by you) [self.nativeAd reportAdClick:"clicks params" withCustomClickTrackerScript :"custom script here"]; //Track clicks using custom URL. (Note: Landing page needs to be opened by you) [self.nativeAd reportAdClick:"clicks params" withCustomClickTrackerURL :"custom click tracking URL here"]; //Track clicks using custom script and let InMobi open the Landing Page [self.nativeAd reportAdClickAndOpenLandingURL:"clicks params" withCustomClickTrackerScript :"custom script here"]; //Track impressions using custom URL and let InMobi open the Landing Page [self.nativeAd reportAdClickAndOpenLandingURL:"clicks params" withCustomClickTrackerURL :"custom impression tracking URL here"];
9. InMobi strongly recommends setting the delegate to nil in the dealloc method, or at any other time of native ad release.
-(void)dealloc { nativeAd.delegate = nil; }
Passing the location object allows for better targeting, and potentially higher eCPMs.
Note: If the location object is passed, the app will ask the user for permission to access their location info.
Use
//Using CoreLocation
to fetch the coordinate.
#import “CoreLocation/CoreLocation.h” CLLocationManager *mgr = [[CLLocationManager alloc] init]; CLLocation *loc = mgr.location; [IMSdk setLocation:loc]; [locationMgr startUpdatingLocation];
//when using custom values [IMSdk setLocationWithCity:@"San Francisco" state:@"California" country:@"USA"];
Turn on debugging by importing the IMSDK class and use it to set different log levels in the SDK:
#import "IMSdk.h"
The available values are:
IMLogLevelNone
: InMobi SDK will not log anything on the console. We recommended that you set the log level to none once you’re distributing the app to the App Store.IMLogLevelError
: InMobi SDK will log only the error information, which can be used by the publisher for debugging.IMLogLevelDebug
: In this mode, InMobi SDK will log everything. Please use this log level strictly in case you experience any issues. Keeping the debug mode turned on might impact performance.Example: Before you load the ad, set the log level to debug as follows:
[IMSdk setLogLevel:IMLogLevelTypeDebug];
The InMobi SDK does not expose any data out of the scope of an application. Any SDK-related data that is persisted is done within the application scope only, without any access to other third-party applications.
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 "IMSDK" provides static methods to set demographic information about the user.
InMobi supports the following parameters:
Description |
Gender of the user
|
Parameter Type |
enum GenderType |
API |
setGender |
Valid Values |
|
Examples |
|
Description |
The education level
|
Parameter Type |
|
API |
|
Valid Values |
|
Examples |
[IMSdk setEducation: kIMSDKEducationHighSchoolOrLess];
|
Description |
Ethnic group of the user
|
Parameter Type |
enum Ethnicity |
API |
setEthnicity |
Valid Values |
|
Examples |
[IMSdk setEthnicity: kIMSDKEthnicityHispanic];
|
Description |
The date of birth of the user |
Parameter Type |
Calendar |
API |
setYearOfBirth |
Valid Values |
NSInteger |
Examples |
|
Description |
Approximate annual household income (in US Dollars) |
Parameter Type |
int, to be specified in $ |
API |
setIncome |
Valid Values |
|
Examples |
|
Description |
The age of the user |
Parameter Type |
int |
API |
setAge |
Valid Values |
|
Examples |
[IMSdk setAge: 22]; |
Description |
The postal code (Usually a 5 digit number). |
Parameter Type |
string |
API |
|
Valid Values |
@"12345" - Please enter appropriate postal code, as applicable. |
Examples |
|
Description |
The area code (part of the telephone number). |
Parameter Type |
string |
API |
|
Valid Values |
@"123" - Please enter appropriate area code, as applicable. |
Examples |
|
Description |
Any additional relevant description of the user, or their preferences, separated by commas. Valid acceptable values are mentioned below. |
Parameter Type |
String |
API |
|
Valid Values |
|
Examples |
[IMSdk setInterests: @"Foodie,Gamer,Sports"];
|
Description |
Indicates a login ID and session ID in the publisher's domain
|
Parameter Type |
|
API |
|
Valid Values |
|
Examples |
|
Description |
The native language of the user (if known) |
Parameter Type |
String |
API |
setLanguage |
Valid Values |
@"ang" - Values are expected in 3 letter codes from ISO 639-2/5. See here for details. |
Examples |
[IMSdk setLanguage:@"ang"];
|
Description |
The house hold income of user in US Dollars |
Parameter Type |
enum HouseHoldIncome |
API |
|
Valid Values |
|
Examples |
|
Description |
The age group of the user |
Parameter Type |
|
API |
|
Valid Values |
|
Examples |
|
Description |
The nationality of the user |
Parameter Type |
String |
API |
|
Valid Values |
Nationality according to the list
here.
|
Examples |
|
Note: Please refer to the SDK bundle to view the change logs for this document.
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.