In order to start setting up, you’ve to ensure that the steps mentioned in the (available InMobi Integration) have already been incorporated.
Step1: Initialise the SDK, after the completion of Initialisation process, completion handler will be called.
void (^completionBlock)(NSError*) = ^( NSError* _Nullable error) {
if (error) {
NSLog(@"SDK Initialization Error - %@", error.description);
}
else {
NSLog(@"IM Media SDK successfully initialized");
}
};
[IMSdk initWithAccountID:kIMAccountID consentDictionary:@{IM_GDPR_CONSENT_AVAILABLE: @"true"} andCompletionHandler:completionBlock];
Kindly refer to the integration document for details about creating the gdpr consent dictionary.
Once you have added the SDK for iOS successfully, please follow the steps below to load the following ad units using Audience Bidding.
Create an Instance of IMBanner.
IMBanner* bannerAd = [[IMBanner alloc] initWithFrame:frame placementId:<placementid>];
To set the delegate of the IMBanner, call:
bannerAd.delegate = self;
Requesting a bid requires IMBanner Instance,. After setting delegate of IMBanner, call preload on IMBannerPreloadManager. IMBanner has an instance of IMBannerPreloadManager as its property.
For requesting bid, call following line.
[bannerAd.preloadManager preload];
Implement the following IMBannerDelegates:
/**
* Notifies the delegate that the banner has recieved the ad with the meta/transaction info.
*/
-(void)banner:(IMBanner*)banner didReceiveWithMetaInfo:(IMAdMetaInfo*)info {
NSLog(@”bid fetched:%@”, info.getBid());
}
/**
* Notifies the delegate that the banner has failed to preload with some error.
* It will only be recieved when preload is called.
*/
-(void)banner:(IMBanner*)banner didFailToReceiveWithError:(IMRequestStatus*)error {
NSLog(@”bid failed to be fetched”);
}
Please do not destroy this instance of IMBanner, as this will be needed if InMobi wins the auction.
In case InMobi has won the auction, then you can call the load
method on the preloadManager property on the IMBanner instance to load the ad.
For loading the banner ad, call following line.
[bannerAd.preloadManager load];
Implement the following IMBannerDelegates:
/**
* Notifies the delegate that the banner has finished loading
*/
-(void)bannerDidFinishLoading:(IMBanner*)banner {
NSLog(@”Banner ad did finish loading”);
}
**
* Notifies the delegate that the banner has failed to load with some error.
*/
-(void)banner:(IMBanner*)banner didFailToLoadWithError:(IMRequestStatus*)error {
NSLog(@”banner ad failed to load”);
}
Create an Instance of IMInterstitial.
IMInterstitial* interstitialAd = [[IMInterstitial alloc] initWithPlacementId:<placementid> delegate:<delegate>];
Requesting a bid requires IMInterstitial Instance,. Invoke the preload method on IMInterstitialPreloadManager. IMInterstitial has an instance of IMInterstitialPreloadManager as its property.
For requesting bid, call following line.
[interstitialAd.preloadManager preload];
Implement the following IMInterstitialDelegate:
/**
* Notifies the delegate that the ad server has returned an ad. Assets are not yet available.
* Please use interstitialDidFinishLoading: to receive a callback when assets are also available.
*/
-(void)interstitial:(IMInterstitial*)interstitial didReceiveWithMetaInfo:(IMAdMetaInfo*)metaInfo {
NSLog(@”bid fetched:%@”, info.getBid());
}
/**
* Notifies the delegate that the interstitial has failed to recieve an Ad(failed to preload an ad) with some error.
* This callback will only be recieved when Preload is called.
*/
-(void)interstitial:(IMInterstitial*)interstitial didFailToReceiveWithError:(NSError*)error {
NSLog(@”bid failed to be fetched”);
}
Please do not destroy this instance of IMInterstitial, as this will be needed if InMobi wins the auction
In case InMobi has won the auction, then you can call the load method on the preloadManager property of the IMInterstitial instance to load the ad.
For loading the interstitial ad, call following line.
[interstitialAd.preloadManager load];
Implement the following IMInterstitialDelegate:
/**
* Notifies the delegate that the interstitial has finished loading and can be shown instantly.
*/
-(void)interstitialDidFinishLoading:(IMInterstitial*)interstitial {
NSLog(@”Interstitial ad did finish loading”);
}
/**
* Notifies the delegate that the interstitial has failed to load with some error.
*/
-(void)interstitial:(IMInterstitial*)interstitial didFailToLoadWithError:(IMRequestStatus *)error {
NSLog(@”Interstitial ad failed to load”);
}
As Interstitial ad is already loaded, to show the interstitial ad call the following:
[interstitialAd showFromViewController:<viewcontroller>];
Implement the following IMInterstitialDelegate:
/**
* Notifies the delegate that the interstitial would be presented.
*/
-(void)interstitialWillPresent:(IMInterstitial*)interstitial {
NSLog(@”interstitialWillPresent”);
}
/**
* Notifies the delegate that the interstitial has been presented.
*/
-(void)interstitialDidPresent:(IMInterstitial*)interstitial {
NSLog(@” interstitialDidPresent”);
}
/**
* Notifies the delegate that the interstitial has failed to present with some error.
*/
-(void)interstitial:(IMInterstitial*)interstitial didFailToPresentWithError:(IMRequestStatus*)error {
NSLog(@” interstitial didFailToPresentWithError”);
}
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.